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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printf problem

Status
Not open for further replies.

subra

Programmer
Aug 6, 2000
45
IN
this is the code

printf("%5s","abcd");

is there any way in which that "5.2" can be replaced by a variable so that formatting can be done on the fly?

like

int a=5;
printf("%as","abcd");

subra if you find this useful let me know at vksubra@icenet.net
 
Yes, use the following code.

int main()
{
int i = 10;
printf("%*S", i, "String");
return 0;
}

This will do.

Regards
Maniraja S
 
dear maniraja s.

thanks a lot for the prompt reply.

yes it did work and helped a lot

regards
subra
if you find this useful let me know at vksubra@icenet.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top