473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

fstream issue. any ideas?

I'm trying to get some information dumped from a program that's giving me
fits, but when i try to use the ofstream class to dump to file, i get a
message from the compiler that it doesn't exist. This is a simple program
for a class (intro to opengl) wich uses only one .cpp file and has included
at the beginning #include <fstream>. the code below is what I know to be
correct for opening and writing to a file, but the ofstream declaration
comes up invalid even though intellisense knows what's going on and gives me
my members lists. could i possibly have a corrupt install? or am i looking
at this crosseyed and my code is wrong? Thanks

ofstream mazestream;
mazestream.open("path.txt", std::ios::app);
for (int i = 0; i < 100; i++)
{
mazestream.write(square[i]);
mazestream.write("\n");
}
mazestream.close();
Nov 17 '05 #1
4 935
You are missing the following:

using namespace std;

Or of course something a bit more granular which is what I would recommend
for production code.

Ronald Laeremans
Visual C++ team

"Tom Andrecht" <an******@oit.edu> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
I'm trying to get some information dumped from a program that's giving me
fits, but when i try to use the ofstream class to dump to file, i get a
message from the compiler that it doesn't exist. This is a simple program
for a class (intro to opengl) wich uses only one .cpp file and has
included at the beginning #include <fstream>. the code below is what I
know to be correct for opening and writing to a file, but the ofstream
declaration comes up invalid even though intellisense knows what's going
on and gives me my members lists. could i possibly have a corrupt
install? or am i looking at this crosseyed and my code is wrong? Thanks

ofstream mazestream;
mazestream.open("path.txt", std::ios::app);
for (int i = 0; i < 100; i++)
{
mazestream.write(square[i]);
mazestream.write("\n");
}
mazestream.close();

Nov 17 '05 #2
On Thu, 14 Oct 2004 09:49:00 -0700, "Tom Andrecht" <an******@oit.edu>
wrote:
I'm trying to get some information dumped from a program that's giving me
fits, but when i try to use the ofstream class to dump to file, i get a
message from the compiler that it doesn't exist. This is a simple program
for a class (intro to opengl) wich uses only one .cpp file and has included
at the beginning #include <fstream>. the code below is what I know to be
correct for opening and writing to a file, but the ofstream declaration
comes up invalid even though intellisense knows what's going on and gives me
my members lists. could i possibly have a corrupt install? or am i looking
at this crosseyed and my code is wrong? Thanks

ofstream mazestream;
mazestream.open("path.txt", std::ios::app);
for (int i = 0; i < 100; i++)
{
mazestream.write(square[i]);
mazestream.write("\n");
}
mazestream.close();


'ofstream' is in the 'std' namespace

declare
std::ofstream mazestream;

Vin
Nov 17 '05 #3
I'm trying to port some old code and have run into the same problem. I'm
usually a VB programmer and it's been 9 years since I've written any C.

I tried putting in the line you suggested towards the top of the first .cpp
file that is called but it did not work. Can you give me a little more
background on where it should go and/or how it should work?

Any help would be greatly appreciated!

"Ronald Laeremans [MSFT]" wrote:
You are missing the following:

using namespace std;

Or of course something a bit more granular which is what I would recommend
for production code.

Ronald Laeremans
Visual C++ team

"Tom Andrecht" <an******@oit.edu> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
I'm trying to get some information dumped from a program that's giving me
fits, but when i try to use the ofstream class to dump to file, i get a
message from the compiler that it doesn't exist. This is a simple program
for a class (intro to opengl) wich uses only one .cpp file and has
included at the beginning #include <fstream>. the code below is what I
know to be correct for opening and writing to a file, but the ofstream
declaration comes up invalid even though intellisense knows what's going
on and gives me my members lists. could i possibly have a corrupt
install? or am i looking at this crosseyed and my code is wrong? Thanks

ofstream mazestream;
mazestream.open("path.txt", std::ios::app);
for (int i = 0; i < 100; i++)
{
mazestream.write(square[i]);
mazestream.write("\n");
}
mazestream.close();


Nov 17 '05 #4
eHaggis wrote:
I'm trying to port some old code and have run into the same problem.
I'm usually a VB programmer and it's been 9 years since I've written
any C.

I tried putting in the line you suggested towards the top of the
first .cpp file that is called but it did not work. Can you give me
a little more background on where it should go and/or how it should
work?

Any help would be greatly appreciated!


How 'bout a little more information about what you're trying to do and
exectly what errors you're running into?

-cd
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Danny Anderson | last post by:
Hola- I didn't get any responses on a previous post, so I am trying to reword my problem and post compile-able code that exhibits the behavior I am describing. On the second iteration of the...
13
by: Don Kim | last post by:
I'm writing a program to read 2,000,000 floating point numbers off a text file, to compute the sum, mean, and median. This is a direct example of Stroustrup's paper. But the program will not...
4
by: Pablo | last post by:
At my current job I've been tasked with maintaining a very old C++ application written largely in ANSI c++ in what I believe to be with an old DOS based Borland compiler. I'm trying to add a...
5
by: derek | last post by:
I see this has come up over and over again in the past... that programmers waste hours of confusion when using a fstream object to open, read/write, close then attempt to open another file (or the...
9
by: Someonekicked | last post by:
In my program, I need to open multiple files, and I wont know till after the program execution how many of them (user will enter that value). So I am using a vector of fstream. I am using fstream...
7
by: Michael C | last post by:
I need to read a text file, "rewind" it to the beginning and read it again. I've tried using fstream's seekg(0, ios_base::beg) method with no luck. For some reason it's still thinking it's at eof,...
6
by: wiso | last post by:
My problem is this (from: http://www.cplusplus.com/ref/iostream/fstream/open.html) #include <fstream> using namespace std; int main() { fstream f;
2
by: jjcp | last post by:
I would like to say thanks in advance for insight anyone can shed on this for me. Long story short from time to time I need to us C++ to take a list of file and make an index out of them in...
6
by: canilao | last post by:
Hi All, So I ran into an issue with using the ! operator with fstream: // Make sure the file is ready to be read before we move on. 1: fstream fileStream; 2: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.