#include <stdio.h>
#include <stdlib.h>
int main()
{
char *str=malloc(sizeof(char)*100);
int length=0;
printf("Enter string :\n");
scanf("%c",str);
while(*str)
{
length++;
*str++;
}
printf("%d",length);
return 0;
}
I'm trying to write a program to find length of string using pointers.But whatever the string, I'm getting the result as 1. Can somebody tell me what's wrong?