Re: Why do i get runtime error ?
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 06 Feb 2009 10:03:13 -0800
Bart <bc@xxxxxxxxxx> writes:
On Feb 6, 3:15 pm, karthikbalaguru <karthikbalagur...@xxxxxxxxx>
wrote:
Is it not possible to use %f and print #define's ?
#define MAX_VAL 100
int main(void)
{
printf("%f", MAX_VAL);
return 0;
}
I get runtime error for the above code .
Any specific reason ?
The error has been explained but this can easily be picked up by your
compiler. Adjust the warning levels for it.
That depends on the compiler. gcc, for example, can diagnose
mismatches between a printf format string and arguments (if the format
is given as a string literal), but I don't know whether other
compilers can do so.
The bottom line is that it's entirely up to you, the programmer, to
make sure that your format string is correct for the argument types
you're feeding it. Some compilers might be able to help you diagnose
the problem, but you can't count on it. The only reliable solution is
to get it right in the first place.
--
Keith Thompson (The_Other_Keith) kst@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- References:
- Why do i get runtime error ?
- From: karthikbalaguru
- Re: Why do i get runtime error ?
- From: Bart
- Why do i get runtime error ?
- Prev by Date: Re: Why do i get runtime error ?
- Next by Date: Re: language extensions needed by linux /usr/include headers
- Previous by thread: Re: Why do i get runtime error ?
- Next by thread: Re: Why do i get runtime error ?
- Index(es):
Relevant Pages
|