Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sprintf, %s%, and arrays

Status
Not open for further replies.

prpleprncs

Programmer
Jul 12, 2002
14
VG
Is there anyway to print and array using:
sprintf(buffer, "%s",errMsg[z]);
m_tadslist.AddString(buffer);
At the moment, it throws an exception.

 
Try to use the function "strcat" instead because in this
case using "sprintf" for trying to append the strings "errMsg[z]" wont work because each time that you copy one of them to the buffer,the previous one will get erased.

try: strcat( buffer, errMsg[z] );
 
And once I have concatenated the array to the buffer, how do i add the concatenation to the listbox
 
that didn't work. think we forgot that buffer was an array used for sprintf.
 
If you have declare "buffer" using a declaration such as
char buffer[const_size];
than you should do "buffer[0] = 0" to initialise the buffer before using it with the function "strcat".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top