C
x
29
1
2
3
4
5
char array[10][100],string[100];
6
int top=0;
7
8
void push(const char* elem) /* use const char* to receive strings that won't be modified */
9
{
10
strcpy(array[top],elem);
11
top++;
12
}
13
14
int main(void)
15
{
16
printf("Enter the string: \n");
17
fgets(string,100,stdin);
18
int length;
19
length=strlen(string);
20
int i=0;
21
while((string[i])!='\0')
22
{
23
char str[2] = {string[i], '\0'}; /* create a string */
24
push(str); /* and push that */
25
i++;
26
}
27
printf("%d",length);
28
}
29
$ gcc prog.c -Wall -Wextra -std=c99 -pedantic
Stdin
hoge
Start
Enter the string: 5
0
Finish