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 - String width/precision using wildcard

Status
Not open for further replies.

CJason

Programmer
Oct 13, 2004
223
US
You know how you can write:
Code:
$result = sprintf("%*s\n",9,"HELLO");
Is it possible to use %*.*s using the same argument value...without having a separate argument?

For example, the "proper" way would be:
Code:
$result = sprintf("%*.*s\n",9,9,"HELLO");
But, I want to do something like this...and have it work correctly:
Code:
$result = sprintf("%*.*s\n",9,"HELLO");
Is there a way to do something like this?

Thanks in advance!
 
None of that makes any sense.

$result is an invalid variable name in C. Variables (and functions) can only use letters, numbers or underscores.

The first parameter of sprintf() must be a char* string variable, not a literal string constant.

What exactly are you trying to do?
 
Sorry, I'm mixing my languages.

I figured out a work-around, so we can close this thread.

Thanks for your response!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top