concatenating strings
#1

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
Reply
#2

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

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 =)
Reply
#4

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

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

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

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

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
Reply
#8

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);

Reply
#9

Код:
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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)