C++ Forum for help

Penth

Senior member
Mar 9, 2004
933
0
0
AT is good for General Hardware and Off Topic, but does anyone know a good active forum for c++ discussion?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
There are some people here that know it fairly well, though actual programming threads tend to get drowned in the sea of gaming threads.
Ars Technicha has a goood programming forum.
There are some good news groups, but come with a thick skin and be prepared for alot of "Read the FAQ" replies.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
For Windows development, www.CodeProject.com

If you're still in school, prepare to get flamed most anywhere if you ask homework questions without showing you've made an effort to do the work yourself.
 

Penth

Senior member
Mar 9, 2004
933
0
0
Thanks. It's not for homework. I'm just working on a project and can't figure something out. I'll check those places out.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
please feel free to describe the problem here as well. some of us do enjoy the occasional puzzle.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Does not hurt to also ask here. Sometimes that answer may exist.
 

Penth

Senior member
Mar 9, 2004
933
0
0
Ok, here's the problem

I want to replace "BATCH0002.DAT" with fileName which will be a string filled with a command line argument containing the filename that was opened with the program. The problem I'm having is no matter what string I put inside the constructor ( ) I get an error. Even if I manually fill string fileName = "BATCH002.DAT" or ("BATCH002.DAT"); it will error. I also need to be able to change the output filename, but I'm sure it is the same answer for both. I've looked around in forums and stuff. It seems like this would be so easy. It seems like every program that you drag a file to takes that filename as an argument and tries to open it.

Let me know if you need the full code. I didn't want to make a mess when I didn't think it was necessary.

ifstream openFile ("BATCH002.DAT");
if (openFile.is_open())
{

while (! openFile.eof() )
{

getline (openFile,line);

oneArray
= stripSpace(line);

q++;

}

openFile.close();
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
have you tried a full path to the file? depending on the working directory when you run your program, you may not be finding the file.
 

wkinney

Senior member
Dec 10, 2004
268
0
0
i can't help but comment that your program could be done on a single line in li/unix...
 

Penth

Senior member
Mar 9, 2004
933
0
0
well, that isn't the full program, that is just the part I'm having problems with. I don't get why the freak ifstream openFile (); has to be manually assigned with the filename instead of using a variable.

and it's not opening the file that is the problem. I've got the program completely working as it is. The only problem is I want it to be able to open a file BATCH001.DAT or BATCH002.DAT and as it is if BATCH002.DAT doesn't exist it won't do anything. Seems kinda stupid to have two different .exes to open the right file name.

Also, the output file is the same thing. You have to put "FILENAME.EXT" instead of a variable that would let you make up the filename when you run the program.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Originally posted by: Penth
filename.c_str() FTW thanks for your help though.

See, some help isa vailable that can be useful here in this forum.