User forums > Using Code::Blocks
BUILD .EXE FILE NOT OPENING ONLY FOR FILE I/O IN C
(1/1)
gautam736:
Every programms are running but only file input output build .exe file is not opening though file programs are compiling and running without errors.
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *f;
char ch;
f=fopen("op.DAT","r");
while(ch!=EOF)
{
ch=fgetc(f);
printf("%c",ch);
}
getch();
}
MortenMacFly:
You do several things wrong:
- You don't verify the file exist,
- You don't verify you got a valid file pointer after fopen
- You most likely didn't put the file "op.DAT" in the working directory of you application which you setup in the project options.
- If you are on Linux: you need to check the file's name as it is case sensitive (a capital letter extension is very un-common on such platforms)
- You said nothing about your build environment -> platform (OS), version etc...
Fixing all this will probably make you app working.
BTW: As this is not related to Code::Blocks, but a general programming question I am locking the topic now.
Navigation
[0] Message Index
Go to full version