Thread: c++ consle app HELP

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    6

    Post c++ consle app HELP

    IS there a way too make that if the user runs a program the programe makes a file and the user then define whats written in the fileIF you dont get it I think this should help:
    you run the app
    the consle app makes a file
    you name the file
    you write whats supposed to be in the file
    the app saves it
    and you type a command to veiw it

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Of course it is. This is programming, not baby-sitting.

    You run the app.
    Console app asks for filename.
    Console app stores input.
    Console app creates new file from input.
    Console app asks for the information to write to the file.
    Console app stores the input.
    Console app writes the input to the file.
    Console app closes file.
    Console app asks you what you want to do.
    Console app awaits input.
    User enters some commands.
    Console app parses the commands and does what the user wants.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    6
    What I need is the code and the user types a command to veiw the file that the user has made but more importantly I need the code

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No, I'm not here to do homework.
    You write the code.
    But if you get stuck, then you ask specific questions about what you have problems with.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Hmm...? gin's Avatar
    Join Date
    Jun 2008
    Location
    Glasgow, Scotland
    Posts
    51
    This always makes me wonder... why do you choose to pick up programming if you don't want to do the programming? You'll benefit more by ATLEAST attempting it. Good luck.

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    6
    Quote Originally Posted by Elysia View Post
    No, I'm not here to do homework.
    You write the code.
    But if you get stuck, then you ask specific questions about what you have problems with.
    This isn't homework but I am stuck really all I need to know is how to put the file name that the user imported into the ofstream line is it some thing like this
    Code:
    //code
    {
    char filename;
    //code
    ofstream a_file("filename")
    //code
    }
    Note:that was a guess

  7. #7
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    It's not homework, but you're trying to get us to do it for free and you "need" it..... right. Have a nice day.

  8. #8
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    What you are describing is the kind of thing easily done in a shell/command line interpreter. So that makes me think, why would you want to do this ? On a POSIX-compliant (or mostly POSIX-compliant, anyway you only need the 'cat' utility, so you would be fine if you are on Windows and have cygwin, and anyway I'm quite sure there's something equivalent native to Windows), it would looks like this:

    Code:
    $ cat - > filename
    You enter your text here.
    It can be multiline.
    When you are done, you press Ctrl+D. (or maybe Ctrl+Z on Windows)
    $ cat filename
    But if you still want to write your own program, well, I'm feeling lazy, so I'm just going to give you this reference. But since there's quite a good amount of info in there, this could be a bit confusing for a newcomer.
    I hate real numbers.

  9. #9
    Registered User
    Join Date
    Jun 2008
    Posts
    6
    Quote Originally Posted by MacGyver View Post
    It's not homework, but you're trying to get us to do it for free and you "need" it..... right. Have a nice day.
    It really isn't homework just a projcet I'm making for fun I figured out parts of it but I just don't know how to get what the user inputed into the ofstream line:
    What I'm talking about:
    Code:
    ofstream a_file( "name of file" )
    ---------------------^________^
                                        How do I get what the user
                                        inputed there?

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by programer345 View Post
    What I'm talking about:
    Code:
    ofstream a_file( "name of file" )
    ---------------------^________^
                                        How do I get what the user
                                        inputed there?
    What's wrong with storing it in a variable?

  11. #11
    Hmm...? gin's Avatar
    Join Date
    Jun 2008
    Location
    Glasgow, Scotland
    Posts
    51
    You should have learned this quite early, usually it's one of the first things you learn .

    I've narrowed it down for you, if you can't find it here then all hope is lost for you:
    http://www.cplusplus.com/doc/tutorial/basic_io.html

    Give that a read.

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by programer345 View Post
    This isn't homework but I am stuck...
    Note: I don't really care if it's homework or not, but the fact is that you're trying to extract code from us for a very simple thing. And that is bad in my eyes and others because we want YOU to learn how to do this, which is why we usually refuse to write the code for you, but help you through coding it yourself.
    It helps you become a better programmer.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by programer345 View Post
    It really isn't homework just a projcet I'm making for fun I figured out parts of it but I just don't know how to get what the user inputed
    That's odd. If you got to the point the user made an input, you already have it stored in a variable. No other way around it as far as I know. That's how cin works.

    So, you just use that variable with ofstream, replacing the meaningful argument with the variable name.

    What exactly are you using to learn C++? Seems to me something is amiss there if they don't explain this. You might want to find a better tutorial.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #14
    Registered User
    Join Date
    Jun 2008
    Posts
    6
    I think I fugured it out!!! is it like this?:
    Code:
    //code
    {
    char filename[20];
    char filetxt[5000];
    //code
    // of stream declaration ( <<  filename << );
    a_file( << filetxt << );
    // code
    }
    ????

  15. #15
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I can see the A+ coming a mile away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  2. best program to start
    By gooddevil in forum Networking/Device Communication
    Replies: 4
    Last Post: 05-28-2004, 05:56 PM
  3. Need help migrating console app to windows app
    By DelphiGuy in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2004, 07:05 PM
  4. pasword app
    By GanglyLamb in forum C Programming
    Replies: 2
    Last Post: 06-07-2003, 10:28 AM
  5. How do I make my Linux app standalone?
    By Joda in forum C++ Programming
    Replies: 2
    Last Post: 11-27-2002, 04:53 AM