LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-26-2008, 05:34 AM   #1
hoshangi
Member
 
Registered: Nov 2007
Posts: 88

Rep: Reputation: 15
problem with files


Hi
i have a problem with files below condition returns true:

File *fp=fopen("Myfile.txt","r+b");
if(fp==NULL)
printf("Error\n");


1-the file is exist
2-the file is Correct
3-the file is not open


this condition works 5 minuets without any problem but after 5 min the error is appear,
a timer open and close Myfile every 5 milisecondes

i don't know what is happen after 5 minuets that this condition returns true





please help me thanks
 
Old 04-26-2008, 05:39 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

Instead of just printf("Error\n") why not print out a more meaningful message? Try e.g.

perror("fopen");
 
Old 04-26-2008, 12:27 PM   #3
hoshangi
Member
 
Registered: Nov 2007
Posts: 88

Original Poster
Rep: Reputation: 15
thanks

for your opinion what is may happen for the file?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in mounting cdrom(audio files running but not reading data files) amit_usual Linux - Newbie 7 12-29-2007 05:52 AM
a strange problem when converting video files to dvd-compatable files d00bid00b Slackware 0 12-01-2006 11:43 AM
Problem linking f77 and f90 object files Make problem (I think) TheBrick Programming 1 05-22-2006 06:17 AM
Problem with .h files tonyfreeman Programming 4 02-04-2006 01:16 PM
problem with all my files jan_bosjes Linux - Newbie 2 01-28-2005 01:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration