Computer Science, asked by curiousbrain2945, 1 year ago

How do you declare a variable that will hold string values in c?

Answers

Answered by Anonymous
0

char name[30]; /* pre-allocated memory of stack */

Then scan that value in. or

char *name = malloc(sizeof(char) * 30); /* run-time allocation on heap */

I am just using 30 here assuming the input string fits in 30 char's you can increase or decrease it , it is up to your wish.

Similar questions