printf a variable in C -
#include <stdio.h> #include <stdlib.h> int main() { int x = 1; printf("please make selection keyboard\n"); sleep(1); printf("1.\n"); char input; scanf ("%c", &input); switch (input) { case '1': x=x+1; printf(x); } return(0); }
i trying make variable add , print variable out can't seem code work.
my output error
newcode1.c: in function ‘main’: newcode1.c:20:2: warning: passing argument 1 of ‘printf’ makes pointer integer without cast [enabled default] in file included newcode1.c:1:0: /usr/include/stdio.h:362:12: note: expected ‘const char * __restrict__’ argument of type ‘int’ newcode1.c:20:2: warning: format not string literal , no format arguments [-wformat-security]
your printf
needs format string:
printf("%d\n", x);
this reference page gives details on how use printf
, related functions.
Comments
Post a Comment