Hi,

I wrote a program to read from one file and then process data and out put to another file, it all works okay but what I am wondering is that my source file will have a different name all the time, but it will always be the same file extension,

std::ifstream fin( "20090715.txt" ) ;

I’m wondering is there some kind of terminal like command
*.txt etc

Thanks, for any help.

The nifty thing about ifstream is that it can open(and create) any type of file. That being said, you can have it prompt you for the file name and append .txt to the end or include .txt to the input. Just be sure to use a *char variable, as it appears to dislike streams.

char *name;
string _name;
cin>>_name;
name=_name;
ifstream myfile(name)

Oh and be sure the .exe is in the same folder.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.