C question

Brandon Sandrowicz brandon-77Z/iqU1yLlrovVCs/uTlw at public.gmane.org
Thu Jul 20 19:16:27 UTC 2006


On Jul 20, 2006, at 1:58 PM, Vlad wrote:

>        First, you use char arrays to store your strings; C has no
> inherent String type:
>
> char command[256];

Something like glib could be used.  glib has a GString type as well  
as a bunch of container formats.

>        Then, print your args or whatever into a buffer, with sprintf 
> ():
>
> sprintf(command, "stuff", command, etc);

sprintf("%s%s","command","args");

The first string is a 'formatted' string (what the 'f' in sprintf  
stands for).  The each %s is replaced by the corresponding string  
that is passed into the function.  So "command" replaces the first %s  
and "args" replaces the second.



--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list