Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The following command getting a syntax error in VS 2005....

int sprintf((char *)cptr,const char *format[cOutBuffer[usLoop]]);
Posted
Updated 19-Nov-13 18:02pm
v2
Comments
Ron Beyer 20-Nov-13 0:25am    
Are you defining a function called sprintf, or trying to call sprintf? If you are calling it, you need something more like:

int wroteChars = sprintf((char*)cptr, const char *format[coutBuffer[usLoop]]);

First point - great telling us it's a syntax error: Any other clues/context?

Second point - unless you're doing some fixed field formatting that's really difficult to achieve with iostreams don't touch sprintf with a barge pole, use std::stringstream instead.

Third point - I'd be really wary of casting const away (which I presume you're doing with the first parameter lacking any other context). If you've declared cptr const somewhere else in your program it was presumably for a reason - i.e. it was pointing to something immutable. Scrubbing that protection is a bit daft.

Fourth point - your second parameter looks like a declaration of an array of arrays of pointers to char, it's not a variable name. That's probably what's causing the compiler to fall over in a twitching heap.
 
Share this answer
 
hi,
try like this
int myVariable = sprintf((char *)cptr,const char *format[cOutBuffer[usLoop]]);

hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900