Hello guys.I am having this problem and i cant understand why.This my code
Once i remove int k; from the place i declare variables it works.But the problem occurs even when i remove maxstrl.My aim is to find the max string lenght and the number of words so i can allocate a two dimensional array with strings but i cant expain why the hell does this happen.Thanks in advance,i am really desperate.Code:#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ FILE *fp; int c;char *str; int str_n=0; int maxstrl=-1; int k; fp = fopen("text.txt", "r"); do { c=fscanf(fp, "%s",str); if (c!=EOF){ printf("%s",str); str_n++; } } while (c != EOF); fclose(fp); printf("\n%d",maxstrl); return 0; }



1Likes
LinkBack URL
About LinkBacks



