Just Joined!
Join Date: Mar 200
|
Original Message
|
Name: NKunzis
Date: March 28, 2008 at 06:04:26 Pacific
Subject: Just Joined!
Join Date: Mar 200OS: LinuxCPU/Ram: Intel / 512Model/Manufacturer: HP |
Comment: hi everybody am having a little problem with open a file with its full path. if((inFile = fopen(Buffer_Queue[i].path,"r")) == '\0'){ printf("Input file coudnt be opened\n"); return 0; } The file cannot be found. Buffer_Queue[i].path ; it s an array with paths of files that i need to read. please help me to find out how to access the file inside the path. Thanks I got the right to be wrong Coz my mistakes makes me strong
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: klint
Date: March 28, 2008 at 07:29:26 Pacific
|
Reply: (edit)A couple of things for you to look up in your C manual: What type does fopen return? And what is the type of '\0'? However, the above is not the cause of your problem. It is something to do with the argument you pass to fopen(). You should check it by adding a debug trace statement immediately above the fopen() call: printf("DEBUG: trying to open '%s'\n", Buffer_Queue[i].path);
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: NKunzis
Date: March 28, 2008 at 09:25:55 Pacific
|
Reply: (edit)i ve added that statement debuging and it s printing the right path of the file. As u said maybe the arguments may be wrong. Coz fopen will search for files within the folder of the program. But i would like to access a folder and read files inside. is threre a command to open a folder? Thanks I got the right to be wrong Coz my mistakes makes me strong
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: klint
Date: March 28, 2008 at 09:45:29 Pacific
|
Reply: (edit)No, fopen will use the current default directory (folder) from wherever you were when you ran the application. Nothing to do with where the application resides. To open a file in a specific folder, use the "/full/path/name" instead of just the name. Or just cd to the required directory before you run the program. Use ls to ensure the file printed in the debug statement really exists. Use cat to make sure the file is readable.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: