Text File Output

This is a discussion on Text File Output within the C++ Programming forums, part of the General Programming Boards category; I know how to read a file ad use it, but Im not sure how to open the file and ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    15

    Question Text File Output

    I know how to read a file ad use it, but Im not sure how to open the file and output its contents on the screen.

    How can I do that in main() in a basic C++ code?

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    92
    You have create an istream object and use it to open up a file. Then you can use some of it's member functions like get to extract either lines or individual characters from the file. Then you can output the results right away or save them in another variable to output at some other time.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    15
    Im not sure if i get what you're saying lol...Im kind of still a beginner...Would u write up a short code as an example please

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    92
    No, what you're asking can easily be found in tons of tutorials, books, and other threads. Just do a search.

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    How could you know how to open a file, read from it and use it, but not know how to print its contents to the screen?

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Just 'cause he knows the code to open a file and use it. Doesn't mean he understands it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. I'm not THAT good am I?
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-19-2006, 10:08 AM
  4. Outputting to a File Modified Text
    By alpha in forum C++ Programming
    Replies: 8
    Last Post: 11-24-2003, 07:39 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

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