+ 2

Can anyone explain me the reason why this code does not work?

#include <stdio.h> int main () { int str; printf("Enter your message:\n"); scanf("%s",&str); printf("message:\t",str); return 0; }

8th Mar 2018, 8:51 AM
Sandeepa Fernando
Sandeepa Fernando - avatar
3 Respostas
+ 2
Got it. So is this right? _____________________ #include <stdio.h> int main () { int str; printf("Enter your message:\n"); scanf("%d",&str); printf("message:%d\t",str); return 0; }
8th Mar 2018, 9:09 AM
Sandeepa Fernando
Sandeepa Fernando - avatar
+ 2
its %s", str) not %d
8th Mar 2018, 10:03 AM
‎ ‏‏‎Anonymous Guy
+ 1
For a string ___________ #include <stdio.h> int main () { string str; printf("Enter your message :\n") ; scanf("%s",&str) ; printf("message:%s\t" str) ; return 0; }
8th Mar 2018, 5:24 PM
Sandeepa Fernando
Sandeepa Fernando - avatar