Hey,
I'm currently working on a C programming assignment but am stuck. I need to prompt a user to enter a filename then I must pass that filename to a function(getdata) and have the getdata function open the file and read the contents of the file.
So im my main function I have:
and the getdata function looks like this:Code:int main(void){ char filename[]; printf("Enter data file:"); scanf("%s",filename); getdata(filename); }
now at the moment I only need help to get the file to open, my problem is I know the first argument of fopen should not be "file[]" I have tested it and it does not work.Code:data getdata(const char file[]){ FILE *data; data = fopen(file[], "r");
Any idea's?
P.S The getdata function prototype was provided by the tutor and can not be changed.
Thanks



LinkBack URL
About LinkBacks


