How stupid am I? I forgot my C++!

scootermaster

Platinum Member
Nov 29, 2005
2,411
0
0
How do you write a file to a different directory in C++?

Right now I'm doing something like fp.open(filename, ios::eek:ut) where filename is a carefully constructed string based on a bunch of stuff. Is there a cleaner way than strcat-ing something like "./mydir/" to the already established string?

I'm lame.
 

kalster

Diamond Member
Jul 23, 2002
7,355
6
81
if you are using String (not c style char[n[) you can use "+" its overload, interally it does a stringcat though
 

scootermaster

Platinum Member
Nov 29, 2005
2,411
0
0
hrmph.

It's a char array right now.

The strcat thing works for putting the files in the right place, but something (I'm guessing cout-ing the filename) completely butchers my Ansi terminal settings and converts everything to garble. So that's not good.

I guess I could just keep two strings around...one "full" one and one with just the filenames. Lord.

This would take 15 seconds in PHP. =]

Thanks for your help and any other hints are appreciated.

Also...I go to USC as well!
 

sao123

Lifer
May 27, 2002
12,653
205
106
Originally posted by: scootermaster
How do you write a file to a different directory in C++?

Right now I'm doing something like fp.open(filename, ios::eek:ut) where filename is a carefully constructed string based on a bunch of stuff. Is there a cleaner way than strcat-ing something like "./mydir/" to the already established string?

I'm lame.


no
 

scootermaster

Platinum Member
Nov 29, 2005
2,411
0
0
Originally posted by: sao123
Originally posted by: scootermaster
How do you write a file to a different directory in C++?

Right now I'm doing something like fp.open(filename, ios::eek:ut) where filename is a carefully constructed string based on a bunch of stuff. Is there a cleaner way than strcat-ing something like "./mydir/" to the already established string?

I'm lame.


no


Really? That's...dumb. Stupid C++. Sigh.