Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Infile/Outfile.c_str() question

Status
Not open for further replies.

lisal

Programmer
Sep 22, 2005
5
US
* Is there another way to open an infile and outfile? I think the problem I am having is the .c_str(). It seems like it only outputs the first string in the whole input file and forgets about the rest. **

#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>

using namespace std;

#define USE_SAVED_MARKER 0

void main()
{
string path = &quot;c:\\projects\\qrt4\\&quot;;
string text = &quot;.txt&quot;;

string filename;
string outfile;

cout << &quot;Enter desired filename: &quot;;
cin >> filename;
filename = path + filename + text;

--> ifstream in(filename.c_str());

cout << &quot;Enter output file: &quot;;
cin >> outfile;

outfile = path + outfile + text;
--> ofstream out(outfile.c_str());
 
You may not be looping properly... you need to physically read in each line.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top