I try to get a text attached to the array but this does not seem to work when I try to use printf
after. It does print a blank space.
char text[10][30]; // 10 is text count and 30 text length
printf("Enter text: ");
text[0]=getchar();
I try to get a text attached to the array but this does not seem to work when I try to use printf
after. It does print a blank space.
char text[10][30]; // 10 is text count and 30 text length
printf("Enter text: ");
text[0]=getchar();
Here is a possible solution to do what you want. Since your length is a fixed 30, fgets is a good candidate.
#include <stdio.h>
int
main(void)
{
char text[10][30];
printf("Input\n");
fgets(text[0], sizeof(text[0]), stdin);
printf("%s\n", text[0]);
}