SA-MP Forums Archive
Strings in array - sscanf - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Strings in array - sscanf (/showthread.php?tid=572024)



Strings in array - sscanf - CrashCar - 24.04.2015

I do not understand the use of strings in array, do not know really like is used.

pawn Код:
sscanf ("hello", "a <s [5]> [10]", arr);
the above code would not work.
Can anyone explain me the use of this?


Re: Strings in array - sscanf - Azula - 24.04.2015

me too i search more explication about this i found this

PHP код:
main ()
{
  new 
test []="Azula is 15 years ";
  new 
text [20];
  new 
i;
  
sscanf (test,"%s %d",text,&i);
  
printf ("%s -> %d\n",text,i);
  return 
0;

my code should print Azula 15 but dosent work


AW: Strings in array - sscanf - rospar - 24.04.2015

@Azula:
Sample:
Код:
main ()
{
  new test[20]="Azula is 15 years ";
  new text[20];
  new i;
  sscanf (test,"s[20]{s[20]}i",text,i);
  printf ("%s -> %d\n",text,i);
  return 0;
}
Your mistake was:
Код:
sscanf (test,"%s %d",text,&i);
Right:
Код:
 sscanf (test,"s[20]{s[20]}i",text,i);
{s[20]}>>> Thats to skip the string "is " in you sample

For more Question u can PM me


Re: Strings in array - sscanf - Azula - 24.04.2015

thanks you but still dosent work (compile fine) it dosent print anythings


AW: Strings in array - sscanf - rospar - 24.04.2015

Ok sry but for me it works.
Quote:

[21:05:07] Azula -> 15




Re: Strings in array - sscanf - Jefff - 24.04.2015

pawn Код:
new array[] = "hello CrashCar how are you";
new arr[5][8]; // 5 arrays each up to 8 characters long (7 + NULL).
sscanf(array, "a<s[8]>[5]", arr);

for(new i=0; i != sizeof(arr); i++)
    print(arr[i]);
should show

pawn Код:
hello - arr[0]
Crashcar - arr[1]
how - arr[2]
are - arr[3]
you - arr[4]
I have never use this so I could be wrong


Respuesta: Strings in array - sscanf - CrashCar - 26.04.2015

Thanks !.

I will discuss this here, not to make a new topic. Why does the code does not work ?.

What use is the code?:

pawn Код:
new array[2];
    new integer;

    sscanf(array,"A<i>(0,2)[2]",integer);

    print(array);



Re: Strings in array - sscanf - Jefff - 26.04.2015

pawn Код:
new array[2];
new integer[2];

sscanf(array,"A<i>(0,2)[2]",integer);

printf("integer[0] = %d\ninteger[1] = %d",integer[0],integer[1]);