Thread: Need to report some things in a text file to the user...

  1. #1
    Registered User
    Join Date
    Dec 2004

    Need to report some things in a text file to the user...

    I need to make a program that asks a user for the name of a text file and reports the number of characters in the text file, and the number of end-of-line characters in the text file. I made a text file called TEXT.txt. I am really completely lost right now...I really don't have anything that makes much sense now, but here it is. Please help me. Thanks.

    int main()
    	ifstream textfile;
    	cout << "Enter the name of a text file: ";
    	cin >> textfile;
, ios::in)
    	return 0;

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Be a lot more specific in future. Tell us what errors you're getting, what the program is doing, what you'd like to do, what you've tried, etc...

    using namespace std;
    Technically the top of your program should look like that - they changed stuff a bit in the latest C++ standard. Older compilers will still use the old style, but I strongly recommend that you update to a new one (Dev-C++ 5.0 beta is great -

    Make sure you're using ifstream's properly - it's been a while since I did it myself but the parameter list in
    Code:, ios::in)
    just doesn't look right to me. Not to mention that you're missing a semicolon at the end of that line.

    And then your program is incomplete. Your while loop has an opening {, never matches it with a closing one, and does nothing.

  3. #3
    Registered User
    Join Date
    Aug 2004
    San Diego, CA
    int x = 0;
    while (!textfile.eof())
        char garb;
    x = x-1;
    cout << x;
    There's one loop. See what you can do with it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM