ifstream and fileIn problems

This is a discussion on ifstream and fileIn problems within the C++ Programming forums, part of the General Programming Boards category; how can i give a file i save a name that the user picks ex.. [CODE] output.open("text.txt"); \ heres where ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    77

    Question ifstream and ofstream problems

    how can i give a file i save a name that the user picks

    ex..

    [CODE]
    output.open("text.txt"); \\ heres where i want to make it so that...
    output << one; \\ it names the txt file based on the users
    .....and so on \\ imputed name.

    thx for the help
    Last edited by jobolikescake; 10-25-2002 at 12:05 PM.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    77
    i tried that but when i go to load that same file it wont load it
    Hooked On Phonics Didn't Work For Me!

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    You should be able to use strcat to add the file extension.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    77
    i dont know how to use that
    Hooked On Phonics Didn't Work For Me!

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    77
    how about this ill post the code for the program, its not done yet but ill point out the places where it is messing up

    p.s. dont comment about the use of goto's, i like them and it makes me program easier even though people say you shouldnt use them.
    Attached Files Attached Files
    Hooked On Phonics Didn't Work For Me!

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Holy hole in a donut batman! Talk about really superfluous use of goto!

    Each one of those gotos could be made into functions, and that way you wouldn't be mocked for using such a terrible programming practice.

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    77
    i know i could make them into functions with something called void and some other stuff but i asked about it one time and everyone acted like i didnt know what i was talking about. so i still dont know how to do it.....poor poor me
    Hooked On Phonics Didn't Work For Me!

  8. #8
    Registered User
    Join Date
    Aug 2001
    Posts
    244

  9. #9
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378
    how can i give a file i save a name that the user picks
    you could also use getline() but don't forget to #include<string> class.
    something like this perhaps...

    [code]
    #include<iostream>
    #include<string>> //for strings, getline()

    int main()
    {

    cout<<"Enter the string being sought:";
    string searchString;
    getline(cin,searchString);
    etc..
    }
    I hope this helped.
    cj
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. FileIn question
    By dAzed in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2004, 02:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21