code with arrays

I am compiling a code using code::blocks on Windows XP and I am getting this message:

Compiling: C:\Dev-Cpp\first-part.cpp
Linking console executable: C:\Dev-Cpp\first-part.exe
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings

and when I build and run the code I get this message:


Checking for existence: C:\Dev-Cpp\first-part.exe
Executing: C:\Program Files\CodeBlocks/cb_console_runner.exe "C:\Dev-Cpp\first-part.exe" (in C:\Dev-Cpp)
Process terminated with status -1073741819 (0 minutes, 21 seconds)

What's the difference between the two and how do I mitigate this and make it work?


2) I have an open file process as follows:

fstream myfile;
myfile.open ("data1.txt");

myfile << " p\n";
myfile << " ydisplacement2\n";

But when I run the code as explained above I never find this file on my hard drive. I am not sure what is going wrong.

Any help is appreciated.
1) The first one is the output from compiling, and the second one is the output from running the compiled code.

The difference is that in the first case, you are building an executable. In the second case, you are running that executable.

There is no mitigation. That's how programming in C++ works. Write some code. Then compile and link it. Then run it.


2) Check that the text file is in the same directory as the executable that is running.
Last edited on
I did make another text file using a simple code and it was located inside that directory, this one however is part of a big code (the one with the running problem) and can not be located anywhere on my hard drive. Is my syntax correct?
Wait, this file doesn't exist on your hard drive? If the file doesn't exist, how do you expect to open it?
I guess he wants to use it for output.
In that case, this should work:

1
2
ofstream myfile;
//...  
Last edited on
Yes. This is what I am using:

ofstream myfile;
myfile.open ("data1.txt");

it's supposed to create a text file with that name but it's not being created for some reason.
I am triying this as well:


ofstream a_file ("data1.txt");

a_file << " p\n";
a_file << " ydisplacement2\n";


Also no result.
It's working now..thank you all.
Topic archived. No new replies allowed.