chumned chumned - 1 month ago 12
C Question

printf() function in C

I can't believe I'm stuck here but I can't seem to get over this.
I want to put a

long
integer in the middle of a sentence.

I get this output;

Howdy, I am 166662
Process returned 0 (0x0) execution time : 0.019 s
Press any key to continue


I am using codeblocks to run this.

#include <stdio.h>

int main(){
long mn = 166662;
printf("Howdy, I am %ld",mn,"i hope that you had a better better day than I having.\n");
return 0;
}

Answer Source

Read the printf spec: First format string, then parameters.

#include <stdio.h>

int main(){
    long mn = 166662;
    printf("Howdy, I am %ld i hope that you had a better better day than I am having.\n", mn );
    return 0;
}