#include <stdio.h>
int main()
{
char text[100];
int length = 0;
gets(text);
while (text[length] != '\0')
length++;
printf("%d",length);
}
I was trying to count the letters in an string using the above program. it worked. But, when i tried the same program with scanf()
instead of gets()
, it didn't work.