Something like this (but this doesn't work):
char name='dotan';
printf("%s", name);
How can I have a vaiable hold a string in C?
use char name[]='dotan';
Reply:char name[6]={'d','o','t','a',''n};
printf("%s", name)
Reply:Use Array of Characters char[]
Reply:char *str = "HELLO";
its a simplest way for the variable to hold a string in C.Over here str points to "HELLO", more over for String manipulation u can include "String.h".Now You can use it as
printf("%s",str);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment