Hi all, I've recently started programming at university and am having a bit of trouble with it. I've begun a piece of work that requires the user to enter a filename, read it into an array, do some maths/statistics and display a variety of results in tables. Annoyingly, I can't get the first part working - my attempt thus far is as follows;
The program seems to freeze as soon as I type in the filename and hit enter; I was under the impression that the scanf would read in whatever I typed to filename, so if I typed for example "statsdata.txt", this would then open the file as if I'd simply typed fptr=fopen("statsdata.txt","r"); normally, so I'm not sure what to do!
FILE * fptr;
printf("Please enter a filename: ");
if (fptr==NULL) printf("Open failed.");
Also, in my file I have 8 numbers seperated by whitespace; if I type out the fptr=fopen("statsdata.txt","r"), these numbers are displayed onscreen. I'm unsure though if these are now in an array or not - is filename here considered to be a string and unrelated to the numbers within?
The program required is pretty complex for my current knowledge, kind of stressing about it which doesn't help either. Thanks a lot for any help you can give.