Code::Blocks Forums
User forums => Help => Topic started by: bassmasta79 on September 12, 2012, 03:37:47 am
-
Hello I am having trouble with Code Blocks reading in files on my laptop. I have been trying to get it to work and am using a simple program to print out a number from a file, and even at the lowest level, Code Blocks seems to have trouble. I think it is a problem with my laptop though, as the exact same code works on other computers.
int main(){
FILE * ifp;
int num, i;
ifp = fopen("numbers.txt", "r");
fscanf(ifp, "%d", &num);
printf("%d", num);
return;
}
I am on windows using latest version of code blocks and the text file is in the same location as the C file.
-
Hello I am having trouble with Code Blocks reading in files on my laptop. I have been trying to get it to work and am using a simple program to print out a number from a file, and even at the lowest level, Code Blocks seems to have trouble. I think it is a problem with my laptop though, as the exact same code works on other computers.
int main(){
FILE * ifp;
int num, i;
ifp = fopen("numbers.txt", "r");
fscanf(ifp, "%d", &num);
printf("%d", num);
return;
}
I am on windows using latest version of code blocks and the text file is in the same location as the C file.
Off topic. But, I suggest putting the text file in the same folder as the created exe file.
You might wish to read the FAQs; especially if this thread is deleted as being off-topic.
http://wiki.codeblocks.org/index.php?title=FAQ (http://wiki.codeblocks.org/index.php?title=FAQ)
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
http://wiki.codeblocks.org/index.php?title=FAQ-Issues_and_Workarounds#Q:_I_posted_on_the_forums_that_Code::Blocks_was_not_working.2C_but_no_one_could_help_me.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Issues_and_Workarounds#Q:_I_posted_on_the_forums_that_Code::Blocks_was_not_working.2C_but_no_one_could_help_me.3F)
Tim S.