Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

run-time error r6001, -null pointer assign

Posted on 1997-11-20
1
Medium Priority
?
1,848 Views
Last Modified: 2012-05-04
I get this error when I run the program (exe) from the command line, but not when I run from inside QuickC and compile into memory. My program has FILE *output; output = fopen("prog07.dat", "a"); print some stuff.... fclose(output); what is my trouble ??
0
Comment
Question by:rogerj
1 Comment
 
LVL 3

Accepted Solution

by:
LucHoltkamp earned 100 total points
ID: 1256386
The fact that a program works when loaded in the debugger but fails when executed stand-alone happens more often.

Never the less, there seems to be a serious problem in your code: you use a pointer wich is not initialized. Check your code, and make sure every pointer you use is initialized. For example:
output = fopen("prog07.dat", "a");
fopen will return NULL when it fails. You should always check the return value of fopen:
if (NULL == (output = fopen("prog07.dat", "a")))
{
  puts("Cannot open \"prog07.dat\"");
  exit(1);
}

Some debug tricks to help you:
1) If you use the DOS platform then the usage of a NULL pointer will overwrite a piece of data in the start of the data segment (DS:0000). The program checks to see if this data has changed, and if it has, it will generate your runtime error. You can leave a inspector open in the debugger on this adres (DS:0000) while your stepping through the program. When you see the data change, the NULL pointer assignment has just happend.
2) You can compile for WIN32, then the debugger will halt your program at the moment the NULL pointer assignment occurs. This is a very handy feature of WIN32, but I don't know if you can compile for WIN32 with QuickC
.luc.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question