Question

i am stuck at a small problem... i have to read data from a .list file but for some reason im just able to do it... i've obviously checked the path many times and i tried copying the data in a text file and using it and it works fine but i really need to read from a .list file.. am i supposed to read differently as compared to a text file? if so how?

here's the code:

#include<iostream>
#include <string>
#include <fstream>
using namespace std;

int main (int args[])
{
    ifstream infile;
    infile.open("D:\transaction.list",ios::in);
    if (!infile) {
        cerr << "Can't open input file " << "D:\\transaction.list" << endl;
        char ch;
    std::cin>>ch;
        exit(1);
    }
}

and this shows cant open file...

here's the list file:

C12397,P342,P8,P563,P456 
C3452,P546,P8,P673,P675 
C1238,P1
C12397,P8,P673,P42

any idea on what im doing wrong? thanks..

Was it helpful?

Solution

\t is a special character in C/C++ you need to pass D:\\transaction.list as a filename

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top