M
Mukesh_Singh_Nick
I am practicing printf formatting options. I want to print out a
string literal as a raw string as opposed to its special meaning. For
e.g I want to print out the "%f" part in:
printf("%f\n");
literally as "%f" rather than a zero value floating point/constant
double (0.000000).
I tried to escape the % sign but the compiler complained with a
warning about an illegal escape sequence.
I am using the Visual C++ 6.0 compiler.
A one-off solution could be to print it out as a string literal as:
char* s = 0;
s = "%f";
printf("%s\n", s);
But that'd work only for this format. I want a flexible solution since
I want to print out many of these formats as literals such as:
"%2.8f"
"%14.3f"
"%.9f"
etc.
string literal as a raw string as opposed to its special meaning. For
e.g I want to print out the "%f" part in:
printf("%f\n");
literally as "%f" rather than a zero value floating point/constant
double (0.000000).
I tried to escape the % sign but the compiler complained with a
warning about an illegal escape sequence.
I am using the Visual C++ 6.0 compiler.
A one-off solution could be to print it out as a string literal as:
char* s = 0;
s = "%f";
printf("%s\n", s);
But that'd work only for this format. I want a flexible solution since
I want to print out many of these formats as literals such as:
"%2.8f"
"%14.3f"
"%.9f"
etc.