X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org From: "Dave Korn" To: References: <13500536 DOT post AT talk DOT nabble DOT com> Subject: RE: can't read sequential files Date: Wed, 31 Oct 2007 11:57:21 -0000 Message-ID: <010101c81bb5$31bcb3a0$2e08a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <13500536.post@talk.nabble.com> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 31 October 2007 00:11, zirtik wrote: > int i; > fp = fopen ("phi.txt","r"); > > for( i = 0; i < 51; i++ ) { > fscanf(fp, "%d\n", &original_phi[i]); > } > 655 [main] Genetics 3012 _cygtls::handle_exceptions: Exception: > STATUS_ACCESS_VIOLATION > 2540 [main] Genetics 3012 open_stackdumpfile: Dumping stack trace to > Genetics.exe.stackdump > if (fp==NULL) > { > printf("error, NULL pointer!\n"); > return(1); > } > > and it is always NULL. You should also print out the value of 'errno' here, it's the global variable that holds the code for the last error from C library functions. > 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. It would tell us a lot if we knew whether errno was equal to ENOENT or EACCES. > I added the current directory > "." to the PATH but it didn't help. Nope, it wouldn't make a difference. PATH is only used by the shell when searching for commands; it isn't used when you're calling fopen. For fopen, you must provide the exact path to the file, or the file must be in the cwd (current directory) when your program is running. > 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. I don't use eclipse myself, but I'd guess there's a setting somewhere for what the current directory should be when it launches the executable. Make sure your text file is in that directory, or change the setting so it points at the debug/release folder where you already put the text file. cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/