Try it like this.
int gLinesWritten, LinesRead, Statements;
float Elapsed;
printf("%s %d %s %d %s","[lines In:",(int)LinesRead,"] [lines Out:",
(int)gLinesWritten,"] ");
printf("%s %d %s %.7G %s\n","[Statements:",(int)Statements,"] [Time:",
(float)Elapsed," sec's]");
John
Hi John:
I suspect that, because of my poor example, you are missing my point. Here's a pair of better examples.
This code
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%s% d%s% d%s\n","Negative: ",-12345," Check alignment? ",67890," Yes");
printf("%s% d%s% d%s\n","Positive: ", 12345," Correctly aligned?",67890," Yes");
return 0;
}
correctly formats the output so that it is properly aligned
Negative: -12345 Check alignment? 67890 Yes
Positive: 12345 Correctly aligned? 67890 Yes
but an improper warning is issued, that is,
snip.c(5): warning #2234:
Argument 3 to 'printf' does not match the format string;
expected 'char *' but found 'int'.
snip.c(6): warning #2234:
Argument 3 to 'printf' does not match the format string;
expected 'char *' but found 'int'.
This code, adapted from your suggested solution to the problem, does not issue a warning
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%s %d %s %d %s\n","Negative: ",-12345," Check alignment? ",67890," Yes");
printf("%s %d %s %d %s\n","Positive: ", 12345," Correctly aligned?",67890," No");
return 0;
}
however, it does not format for the desired alignment.
Negative: -12345 Check alignment? 67890 Yes
Positive: 12345 Correctly aligned? 67890 No
I hope that I have made my point understandable.
Robert Wishlaw