Subject: Re: can't read sequential files
From: Jim Marshall <[email-masked]>
To: [email-masked]
Date: Tue, 30 Oct 2007 22:35:47 -0400
Newsgroups: gmane.os.cygwin
List-Id: <cygwin.cygwin.com>

zirtik wrote:
> Hi, I'm using cygwin and windows XP together with Eclipse IDE and CDT. I have
> a following piece of code:
> 
> ....
> 
> 	int i;
> 	fp = fopen ("phi.txt","r");
> 	
> 	for( i = 0; i < 51; i++ ) {
> 		fscanf(fp, "%d\n", &original_phi[i]);	
> 	}
> 
> ...
> 
> and when I try to compile it, it compiles well, but when I try to run it I
> get the following error message:
> 
> 655 [main] Genetics 3012 _cygtls::handle_exceptions: Exception:
> STATUS_ACCESS_VIOLATION
> 2540 [main] Genetics 3012 open_stackdumpfile: Dumping stack trace to
> Genetics.exe.stackdump
> 
> I added the following line to check if fp is always NULL:
> 
> if (fp==NULL)
> {
>    printf("error, NULL pointer!\n");
>    return(1);
> }
> 
> and it is always NULL. I put the "phi.txt" in the same directory as the
> executable so it is in:
> 
> ....\ProjectFolder\Debug  
> 
> folder as well as in
> 
> ....\ProjectFolder\src
> 
> folder. I still keep getting the same error. I added the current directory
> "." to the PATH but it didn't help. This code used to run on another PC with
> Eclipse and cygwin again but this is the first time I am having problems
> with it on a different machine. Any help would be greatly appreciated. 
> 
> Thanks.
> 
> 
> 
Maybe you don't have read access to the file? You could also check errno 
(see perror, or strerror functions) to see what the error is.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/