ok here's the current situation:sprintf(blah, "%c%-.6s%c", QUOT, varName, QUOT);my question is, how can i use a variable instead of that 6 in there?because i'm supposed to print a whole bunch of strings with variable size (

Recommended Answers

All 3 Replies

replace the 6 with a star then put the variable in the parameter list

sprintf(blah, "%c%-.*s%c", QUOT, 6, varName, QUOT)

ahh thanks man
works like a charm :)

would have been nice if the project wasn't reassigned to smn else..

sprintf(str_name,"%d",int_name);/*INT*/
sprintf(str_name,"%f",float_name);/*FLOAT*/

where
int/float_name:The name of the values which has to be converted into string.
str_name :The string in which the converted value has to be stored.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.