Skip to main content
gamedev.net
🔒 Locked

Strange file Problem

Started by RapidStunna 5 replies 550+ views
Original Post
RapidStunna
RapidStunna
I tried the following code in mscv++: #include "stdio.h" #include "windows.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { FILE* f; f=fopen("wg.txt","r"); if(!f) MessageBox(0,"","",MB_OK); fclose(f); return 0; } That makes sense to me but it doesn''t load right and displays that message box. The file wg.txt exists - I''ve checked and double checked. Does anyone have an idea why it doesn''t load correctly? ---
Brent Gunning | My Site
Colin Jeanne
Colin Jeanne
Shouldn''t

#include "stdio.h"
#include "windows.h"

be

#include <stdio.h>
#include <windows.h>

Otherwise.... are you absolutely sure that the file is in the program''s directory?




Qui fut tout, et qui ne fut rien
Invader''s Realm
Punx
Punx
If you''re running from the IDE make sure the file is in either the Debug or Release directories, whichever mode you are using.
~punx
RapidStunna
RapidStunna
Thanks for your responses. However, it still does not work. Yes I'm sure the file is in the directory. I uploaded my project here if you want to try it.

---
Brent Gunning | My Site

[edited by - RapidStunna on March 21, 2003 11:30:57 PM]
DerekSaw
DerekSaw
quote:
Original post by Punx
If you''re running from the IDE make sure the file is in either the Debug or Release directories, whichever mode you are using.

For MSVC4/5/6, the ''current working directory'' is same as the project file (.dsp) by default.
"after many years of singularity, i'm still searching n the event horizon" o
Brother Bob
Brother Bob
The file in th project you uploaded is named "wg.txt.txt", not "wg.txt" which you try to open. Unless that was a mistake when creating the ZIP-file, my guess is that you don''t have "Show extensions for known filetypes" enabled in explorer, so you only see "wg.txt".
RapidStunna
RapidStunna
Thanks Bob. I knew it had to be a simpe mistake, but I just couldn''t locate it. Haha no wonder I wasn''t getting my files loaded.

---
Brent Gunning | My Site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.