+ 3
How to get character data in c program
How can I get this 'Loyal' character data in C program??? scanf("%c",&Var); Or scanf("%s",&Var); Or scanf("%ch",&Var); And print the actual text!
1 Respuesta
+ 4
In C, you have to differentiate between char (single letters) and strings, which are char arrays.
A char might be declared and initialized like this:
char letter = 'a';
And a string like this:
char word[] = "alpha";
Pay attention to the different quotation marks, that's no coincidence!
Now in order to write into a char (single letter), you use:
scanf("%c", &letter);
And in case of a string you write:
scanf("%s", word);
Pay attention to the string not having an & - that's because an array variable, if you don't index it, is already an address.