[ROZWIĄZANE] Ciągi znaków - maksymalna dłu...
Najlepsza odpowiedź Puchate 09.07.2014 22:37
Do AMXMODX używamy PAWNA, który wymaga zakończenia stringu. W SourcePawnie (bo o nim mówisz) w tym rodzaju zmiennej nie ma takiego wymogu.
//This will declare a number array "myString" that contains the data "Hello".
//It will have 6 slots, because there are 5 characters.
//The last slot is reserved for the number 0, which tells the Pawn engine that it is a string.
new myString[] = "Hello"
// If you're using SourcePawn, do this instead:
new String:myString[] = "Hello"
Przejdź do postu
sebul
09.07.2014
Często widzę (nawet w dokumentacji), że przy operacjach na ciągach, jako maksymalną długość podaje się "sizeof(nazwa_ciagu)", albo też
new String:tab[32]; Format(tab, 32, "Jakiś tekst");jak należy na to patrzeć? W sm zrobili jakoś, że ostatni znak nie musi być "zerem"? Czy już w samym silniku jest to pilnowane i typ String po prostu zawsze ma jakiś dodatkowy znak zakończenia?
Najlepsza odpowiedź
Puchate
09.07.2014
Do AMXMODX używamy PAWNA, który wymaga zakończenia stringu. W SourcePawnie (bo o nim mówisz) w tym rodzaju zmiennej nie ma takiego wymogu.
//This will declare a number array "myString" that contains the data "Hello".
//It will have 6 slots, because there are 5 characters.
//The last slot is reserved for the number 0, which tells the Pawn engine that it is a string.
new myString[] = "Hello"
// If you're using SourcePawn, do this instead:
new String:myString[] = "Hello"