Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading a file with full directory entry

Status
Not open for further replies.

kshk

Programmer
Aug 28, 2002
8
IN
how can i read a file from any specified directory? at present i can only read files that r in the same directory as the .exe
 
If you know the directory you want to use, then supply
the full path of the file to your code eg
FILE *ffp
ffp== fopen("/data/inbox/myfile", "w");


HTH

Dickie Bird (:)-)))
 
dickiebird has added an extra = in his code snippet, == will be an equate test not an assignment of the return code from the fopen call to the ffp variable.

He should have written

ffp=fopen("/data/inbox/myfile","r");


or event

if((ffp=fopen("/data/inbox/myfile","r"))==NULL)
{
/* Handle file missing */
}
else
{
/* Handle file present */
}

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top