-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I'm writing an external merge sort. It works like that: read k chunks from big file, sort them in memory, perform k-way merge, done. So I need to sequentially read from different portions of the file during the k-way merge phase. What's the best way to do that: several ifstreams or one ifstream and…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Here's probably a very noobish question for you: How (if at all possible) can I return an ifstream from a function?
Basically, I need to obtain the filename of a database from the user, and if the database with that filename does not exist, then I need to create that file for the user. I know how…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I've been all over the ifstream questions here on SO and I'm still having trouble reading a simple text file. I'm working with Visual Studio 2008.
Here's my code:
// CPPFileIO.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <fstream>
#include <conio…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
So I am writing a program that deals with reading in and writing out to a file. I use the getline() function because some of the lines in the text file may contain multiple elements. I've never had a problem with getline until now. Here's what I got.
The text file looks like this:
John Smith …
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
No matter what I try, I cant get the following code to work correctly.
ifstream inFile;
inFile.open("sampleplanet");
cout << (inFile.good()); //prints a 1
int levelLW = 0;
int numLevels = 0;
inFile >> levelLW >> numLevels;
cout << (inFile.good()); //prints a 0
at the first…
>>> More