SA-MP Forums Archive
concatenating strings - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: concatenating strings (/showthread.php?tid=109853)



concatenating strings - iLinx - 22.11.2009

nevermind, found what i needed

i never really had to do this before but today when i started to take a look into mysql and samp i realized that having some queries that are multilined strings will be easier to read


Re: concatenating strings - dice7 - 22.11.2009

pawn Код:
new string[128];
format(string, 127, "Random stuff: %d, %s", userID, username);
printf(string);
https://sampwiki.blast.hk/wiki/Format


Re: concatenating strings - iLinx - 22.11.2009

Quote:
Originally Posted by dice7
pawn Код:
new string[128];
format(string, 127, "Random stuff: %d, %s", userID, username);
printf(string);
https://sampwiki.blast.hk/wiki/Format
thats not concatenation, well not what im looking for

ie java:
Код:
System.out.println("Hello " + 
"world");
php:
Код:
$str = "hello" . "world";
thanks anyways though; i made a script which converts the lines for me so it should make my life easier now =)


Re: concatenating strings - -xy! - 23.11.2009

For concatenate strings you can use the function strcat.
Example:

pawn Код:
main ()
{
 new str[10] = "This is";
 strcat(str, "a test!");
 print(str);
}
Simple!


Re: concatenating strings - Enzo_Ferrari_V12 - 26.11.2009

Can you explain this in depth? It would be really useful to me.


Re: concatenating strings - Balon - 26.11.2009

pawn Код:
printf("hello " "world");



Re: concatenating strings - -xy! - 26.11.2009

Quote:
Originally Posted by [KG
Nikere ]
Can you explain this in depth? It would be really useful to me.
Concatenate strings, you add a string to another. To deepen this subject, visit this site:

http://en.wikipedia.org/wiki/Strcat


Re: concatenating strings - Enzo_Ferrari_V12 - 26.11.2009

This is as simple as it gets and it's understandable

Quote:

char str1[100] = "Hello,"; /* 100: reserve extra space */
strcat(str1, " world!");
puts(str1);




Re: concatenating strings - -xy! - 27.11.2009

Код:
char str1[100] = "Hello,"; // is creating a variable of type char str1 call and is stored inside the word hello.
strcat(str1, " world!"); // is concatenating the str1 (Hello) with another string (World)
puts(str1); // printing in the console output: Hello World!
Simple.