c - Why it doesn't print the "Hello"? -
this code compiles without errors why doesn't print "hello" after 5?
#include<stdio.h> #include<conio.h> int main() { int number = 5; printf("%d",number,"hello"); getch(); }
you need %s
placeholder in addition %d
placeholder. see below:
printf( "%d %s", number, "hello" );
... notice "hello"
string literal (and hence null
terminated string), meaning %s
placeholder required if wish pass "hello"
argument. since using string literal, suggest follows:
printf( "%d hello", number );
remark:
- the
%d
placeholder integer. - the
%s
placeholder string (null
terminated array of characters).
Comments
Post a Comment