Should help some.Code:for(j=0;i<50;i++) //use i not j, { printf("Input %d is %s\n",i,namearr[i]); }
Should help some.Code:for(j=0;i<50;i++) //use i not j, { printf("Input %d is %s\n",i,namearr[i]); }
Yes thanks!
The final successful code is:
But still I can't find a way to stop prompting the user for strings if he has entered some number of strings less than 50 and has no more to add.Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i,j; char namearr[50][50]; printf("please enter the names you want in the file (limit is 50 names)"); for(i=0;i<50;i++) { printf("Type name entry %d\n",i); scanf("%s",&namearr[i]); } for(j=0;j<50;j++) { printf("Input %d is %s\n",j,namearr[j]); } system("PAUSE"); return 0; }
And still I don't understand why:
doesnt work or compile for that matter as a for loop and returns error mentioned earlier...Code:for(int i=0;i<50;i++)
Ok, here comes the "looking stuff up" part... Take a look at the stuff in your entries loop. Actually look them up in the C library documentation and study how they work... Does anything in that documentation suggest a way of ending the loop?
That's because of the for (int i ... With the declaration inside the braces is a C-99 enhancement and you are not using a C-99 capable compiler.doesnt work or compile for that matter as a for loop and returns error mentioned earlier...Code:for(int i=0;i<50;i++)
Yet another case for looking stuff up.
Seriously... Do you know the 4 rules of computer bliss?
1) Read the effing screen
2) Read the effing help file
3) Read the effing manual
4) Ok, now you can ask your question.
Seriously... This has been around for years and years... Ever heard RTFM... well, that's were it comes from.