| delorie.com/archives/browse.cgi | search |
| From: | Oon Lin <sci-okl AT jcu DOT edu DOT au> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | fopen() gives Segmentation Fault. Help ? |
| Date: | Thu, 13 Nov 1997 13:09:05 +1000 |
| Organization: | University of Queensland |
| Lines: | 48 |
| Message-ID: | <Pine.OSF.3.96.971113125536.13260B-100000@barra.jcu.edu.au> |
| References: | <3 DOT 0 DOT 16 DOT 19971111193131 DOT 35afdc80 AT hem1 DOT passagen DOT se> <3468C09B DOT 436A AT nortel DOT ca> |
| NNTP-Posting-Host: | cuda.jcu.edu.au |
| Mime-Version: | 1.0 |
| In-Reply-To: | <3468C09B.436A@nortel.ca> |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
I'm having problem using fopen() in DJGPP. What happened is that I made a
first fopen() call to open a file for reading only and that works
fine..and when I call the second fopen() (after I closed the first
fopen()) it just gives me General Protection Fault with Segmentation
violation .... anybody has any ideas ??
// I'm reading in a text file and then write something back to the same
// file. The file access.txt is a text file residing in the same directory
// as my current directory in which I'm doing programming work
// The code snippet
FILE *fileptr ;
// This part works fine. It can open the file
if ((fileptr = fopen("access.txt","r")) == NULL) {
printf("Can't open file !\n");
}
// Close the file without doing any file reading
fclose(fileptr);
// Open the same file for writing
fileptr = fopen("access.txt","w") ; // This statement causes Seg Fault
fclose(fileptr); // Program aborts without reaching here ...
Thanks for reading through the code !
Kean
////////////////////////////////////////////////////////////////////////////
//
Lin Oon Kean // Kean's Corner In The World Wide Web :
email : Oon DOT Lin AT jcu DOT edu DOT au // http://lionfish.jcu.edu.au/~sci-okl
//
///////////////////////////////////////////////////////////////////////////
"Computer Science is the recipe for stress and freaking out"
////////////////////////////////////////////////////////////////////////////
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |