string to character problem--maybe?
From: Darrell (mcdougal48_at_cox.net)
Date: 02/09/05
- Next message: Friedrich Dominicus: "Re: Free opensource IDE for C"
- Previous message: C++ Programmer: "Re: Other Books like AC++"
- Next in thread: John Peters: "Re: string to character problem--maybe?"
- Reply: John Peters: "Re: string to character problem--maybe?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 8 Feb 2005 23:43:17 -0800
I need to open a number of files. I want to be able to change the
name of the file in the program.
#include "stdafx.h"
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
#include<sys/types.h>
#include<stdio.h>
#using <mscorlib.dll>
using namespace std;
int _tmain()
{
string filename;
string cc[8031];
// *********** Open Input File
// I want to be able to replace aapl.csv with ibm.csv dal.csv etc.
//I do this by reading the names from a file
// I have already created.
filename = "c:\\stkdata\\aapl.csv";
ifstream file_in;
// If I use this line, the program runs
file_in.open("c:\\stkdata\\aapl.csv");
//If I us this line, the program aborts
file_in.open(filename);
//I want to be able to change filename on the fly
// this is the error message I get
//readtxt.cpp(25): error C2664:
'void std::basic_ifstream<_Elem
,_Traits>::open(const char *,std::_Iosb<_Dummy>::openmode,int)'
: cannot convert parameter 1 from 'std::string' to 'const char *'
// with
// [
//
_Elem=char,
// _Traits=std::char_traits<char>,
// _Dummy=int
// ]
//Any suggestions greatly appreciated
- Next message: Friedrich Dominicus: "Re: Free opensource IDE for C"
- Previous message: C++ Programmer: "Re: Other Books like AC++"
- Next in thread: John Peters: "Re: string to character problem--maybe?"
- Reply: John Peters: "Re: string to character problem--maybe?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|