Since this is my first post in this forum, I start with "HEY GUYS!".
I've tried to find a solution to my problem, but the only thing I found out was that it has something to do with a wrong value assigned to wordlenght. I've looked through the code but can't find the problem. Also it is to say that the program works just fine but after it's finished it gives me the error message seen in the thread title.
It would be awesome if someone could take a look at the code and explain to me what's wrong or why this message comes up.
Code:
#include <stdio.h>
int main()
{
int i=0,
j=0,
l=0,
wordlength[60];
char inputstring[81];
for(l=0; wordlength[l]<=60; l++)
{
wordlength[l]=0;
}
printf("Enter a sentence: ");
fgets(inputstring, 81, stdin);
for(i=0; inputstring[i] != '.'; i++)
{
if(inputstring[i] != ' ')
{
if(inputstring[i] >= 'a' && inputstring[i] <='z' || inputstring[i] >= 'A' && inputstring[i] <= 'Z')
{
j++;
}
else
{
printf("\nNOT VALID");
break;
}
}
else
{
wordlength[j]=wordlength[j]+1;
j=0;
}
if(inputstring[i+1]=='.')
{
wordlength[j]=wordlength[j]+1;
}
}
for(l=0; wordlength[l]<=60; l++)
{
if(wordlength[l]!=0)
{
printf("Length %d: %d\n", l, wordlength[l]);
}
}
}
Thanks and sorry for my bad english.