File not being created.

Hey all, I'm new here. I'm writing code for a project that interfaces a piece of hardware. My problem right now is that I want to save the data I get from the piece of hardware.

The issue is that when I type

1
2
3
4
5
6
7
8
9
#include <fstream>
#include <stdio.h>
#include <string.h> <------ these are my headers. The actual code is in a sub-function somewhere

using namespace std;

fstream workingFile("AllBinFile.txt", fstream::in | fstream::out);
workingFile << "FFFFFUUUUUUU........." << endl;
workingFile.close();


Absolutely nothing happens. Let me give you a bit more background. I worked on this already and got it to work. I was then told I needed the file to be a binary file, so I started playing around with that. That's when I first noticed that the file wasn't being generated. Eventually I just wanted to see if I'm still sane, and I guess not, because now that I've gone back to a text file, it's still not being created.

Funny thing is, I get absolutely no error. Not from the compiler nor at run-time. Later on in the code I have to create another file to parse the data from the first one. That file gets created just fine. I even stuck that snippet of code into my main() function and still no dice.

What could possibly be causing this?
First, never use the .h system headers when writing C++ code.

#include <iostream>
#include <string>

You may have to read some HW documentation to understand how data can be output to a file. Is your program being written to NVRAM? When writing anything to a stream how will the data get back to the PC?
Nevermind, I figured it out. Basically, adding in the extra fstream:: parts made it not do those parts. I took that part out and things are fine now. *sigh* so many hours of my life wasted on that...

However, thank you for your advice on not using .h system headers. I'll make sure to avoid them in C++.
Topic archived. No new replies allowed.