X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <13524102.post@talk.nabble.com> Date: Wed, 31 Oct 2007 23:43:21 -0700 (PDT) From: zirtik To: cygwin AT cygwin DOT com Subject: Re: can't read sequential files In-Reply-To: <13500536.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: banabulasma AT gmail DOT com References: <13500536 DOT post AT talk DOT nabble DOT com> X-IsSubscribed: yes 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 After adding the line: if (fp==NULL) { printf("error, NULL pointer!\n"); return(1); } and then rebuilding the code, everything worked. But it's strange that if I delete that code segment and never check whether the fp pointer is NULL or not, I always get a segmentation fault. Can this be some kind of an optimization problem? I don't know why it happens. Thank you for the comments. 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. > > > > -- View this message in context: http://www.nabble.com/can%27t-read-sequential-files-tf4722128.html#a13524102 Sent from the Cygwin list mailing list archive at Nabble.com. -- 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/