LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Add two strings

Solved!
Go to solution

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

 

0 Kudos
Message 1 of 5
(3,651 Views)
Solution
Accepted by topic author Tonave

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!

Message Edited by jr_2005 on 03-12-2009 02:57 PM
0 Kudos
Message 2 of 5
(3,647 Views)

Ok it works!!!

 

Thanks a lot jr  Smiley Wink

0 Kudos
Message 3 of 5
(3,642 Views)
I simply add that in case you prefere there is a french speaking forum community here. You can access it via the "Select community" selector in the upper right corner of the page.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 5
(3,637 Views)

For sure I prefere!

Thank you!

0 Kudos
Message 5 of 5
(3,634 Views)