consider this simple C query of mine...
consider this simple code..
#include <stdio.h>
int main(void)
{
float sum = 3.3;
printf("\n%s%12f\n\n sum:", sum);
return 0
}
---- (My queries move from left to right.. of the printf)
1. the first \n causes the cursor to advance to the next line... yes?
2. how about the first %s ? will it correspond to sum even if it (sum) has no double quotes ?
3. how about %12f? to which will it correspond ?
4. then the cursor advances 2 lines next.... right ?
5. will it print the word sum: ?
---my apologies... but I have no idea (as yet..) of running C programs.. Thats why Im asking for advice... I soon will !!
please advise me .... thanks !
Re: consider this simple C query of mine...
Quote:
Originally posted by imbecile in C
consider this simple code..
#include <stdio.h>
int main(void)
{
float sum = 3.3;
printf("\n%s%12f\n\n sum:", sum);
return 0
}
>---- (My queries move from left to right.. of the printf)
>1. the first \n causes the cursor to advance to the next line... yes?
Yes
>2. how about the first %s ? will it correspond to sum even if it (sum) has no double quotes ?
Yes, and will print junk becase sum is a float
>3. how about %12f? to which will it correspond ?
Nothing. you need 2 elements for a 2nd %
>4. then the cursor advances 2 lines next.... right ?
Yes
5. will it print the word sum: ?
Yes.
What I believe you want is:
printf("\nsum=%12f\n\n", sum);