[Dev-C++] Can't run a simple program
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ecpin <ec...@ne...> - 2005-04-07 09:13:47
|
Hi,
After many years I returned to C and used Bloodshed Dev-C++ IDE v4 to
code a simple routine (as MS-DOS/console application) that should print
a text file.
But, even though the code looks correct and compiles succesfully, when I
run the program, windows displays the following error msg and the
program terminates.
**- error msg:
PrintMe.exe - Application Error
The instruction at "0x78024222" referenced memory at "0x0000000c".
The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
<OK BUTTON> <CANCEL BUTTON>
**- end of error msg
The code I wrote is reproduced below:-
**- code begins:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char str[80];
FILE *fp, *stdprn;
if ((fp = fopen(argv[1], "r")) == NULL)
{
if ((stdprn = fopen("PRN", "w")) == NULL)
while(!feof(fp)) { // error occurs here,
fgets(str, 79, fp); // or here
fprintf(stdprn, "%s", &str);
}
}
fclose(fp);
fclose(stdprn);
return 0;
}
**- code ends
Pls advice what could be wrong
Rgds
R3
|