Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

ifstream bullshit

Name: Anonymous 2009-10-26 22:55

Why does c++ have to be so finnicky about strings? I've looked everywhere but found nothing on how to get ifstream to open a file from user input. Can you guys help me? I want this code to work but it just isn't happening. How can I make it work?

string input;
cin >> input
  ifstream myfile;
  myfile.open (input);

Name: Anonymous 2009-10-26 23:05

Because it's C++

Name: Anonymous 2009-10-26 23:32

/prog/ is still full of
bullshit

i see

Name: Anonymous 2009-10-27 0:34

i don't know sepples, because sepples is crap.
but if you're getting the file name from stdin trying taking off the trailing newline character (replace it with null).

Name: Anonymous 2009-10-27 0:49

trailing newline character?

Name: Anonymous 2009-10-27 0:56

>>5
if it's not there then that means cin removes it and you should look for a different reason for your problem.

Name: Anonymous 2009-10-27 1:00

no it's not a problem with what the user inputs, it's a problem with the code. it won't compile like that.

Name: Anonymous 2009-10-27 1:05

Too much masturbation.

Name: Anonymous 2009-10-27 6:43

REMEMBER FOLKS - YOU CAN STILL USE STDIO IN C++

Name: Anonymous 2009-10-27 6:55

>>9
Please don't make C++ slightly more useable

Name: Anonymous 2009-10-27 11:11

>>10
FACT: You can write C++ just like it's C and only use a few extra features that you need.


gg

Name: Anonymous 2009-10-27 11:31

>>11
this post suggests that C programmers need to use C++ features. i'm quite sure you meant "that you want", and, well, we actually do not want.

Name: Anonymous 2009-10-27 12:31

>>12
Yes, that's what I meant.  I'm into C myself and never bothered trying to become skilled in Sepples.

Name: Anonymous 2010-12-06 9:47

Back to /b/, ``GNAA Faggot''

Don't change these.
Name: Email:
Entire Thread Thread List