Hey Thantos .. I was wondering if you could help me with another problem. I searched the board but couldnt find an answer.
I have this declared:
Code:
typedef char * String;
I want to get the name of the file to open as a command line argument so I have this:
Code:
if(argc == 2) {
fprintf(stderr, "%s \n", argv[1]); // to test
input = openFile(argv[1]);
}
This is my parameter list for openFile():
Code:
FILE * openFile(String filename)
In openFile I also print out the name of the file I am trying to open followed by a success or fail message. This is my output.
Code:
[mgimbl@localhost project1]$ Main test.dat
test.dat
Opening test.dat ... success!
****
Only problem is it doesnt open the file. It says it does, but it really doesnt. When I go to print out what was opened, it says no data is in the program. I dont know what my problem is. Is it because I didnt malloc memory for a new String? When I malloc memory for a String, and then use strcpy I dont know how to dereference argv[1] to copy it into my temp String (and I dont know if that is the approach I am supposed to take) .. could you shed some light on this topic please.