03-12-2009 09:07 AM
Hi everybody!
First i'm sorry for my English because i'm French.
So i would like to add to strings. For exemple, I have : "GPIB0::13::INSTR". 13 is in a char array called ADD.
So I would like to do : "GPIB0::" + ADD + "::INSTR" but I can't!!!!
How can I do this please?
Thanks for your answer!
Tonave
Solved! Go to Solution.
03-12-2009 09:56 AM - edited 03-12-2009 09:57 AM
You can add strings in C in the following way:
char str [256];
strcpy (str, "First string " ); // Initialise string to first bit
strcat (str, "Second string " ); // 'add' second bit
strcat (str, "Third string" ); // You've probably got the idea by now...
Although I prefer the more general method of constructing strings:
sprintf (str, "%s %s %s", "First string", "Second string", "Third string" );
because this gives much more flexibility - see the help for sprintf() for a fuller description.
JR
Edit: to try to get rid of the smilies!
03-12-2009 10:08 AM
Ok it works!!!
Thanks a lot jr
03-12-2009 10:21 AM
03-12-2009 10:29 AM
For sure I prefere!
Thank you!