#include <stdio.h>
#include <string.h>
void main()
{
int i=0;
char str[40];
printf("Program to know the string size\n");
printf("Enter a string with more than 2 words: ");
scanf("%s", str);
while(str[i]!='\0')
{
i++;
}
printf("result of while loop %d\n",i);
printf("result of strlen is %d\n", strlen(str));
printf("getting wrong output\n");
}
it counts size of only one word. but i need size of entire string. please help.