File Reading Problem

This is a discussion on File Reading Problem within the C++ Programming forums, part of the General Programming Boards category; Hello, everyone. Like to thank all those who took the time to look at this thread. I'm in need of ...

  1. #1
    Registered User
    Join Date
    Mar 2005

    File Reading Problem

    Hello, everyone. Like to thank all those who took the time to look at this thread. I'm in need of some assitance. I'm trying to get a program to read from the second line instead of the first line of a txt file. Here is what I have so far:

    #include <iostream.h>
    #include <fstream.h>
    int main()
      char a[200];
      ifstream inFile("a:\\joey.txt", ios::in);
    That makes it get from the first line. But everything I've tried to make it read from the second instead, hasn't worked. So can anyone help me out?

  2. #2
    Registered User
    Join Date
    Jan 2005
    the post what u have done is not relavent to this board. this is 'C' board form.


  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Moved to C++ board.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    try this:
    #include<iostream>  //standards-compliant header
    #include<fstream>   //same as above
    int main()
        char*line=new char&#091;256&#093;;
        std::fstream file("Untitled1.dat",std::ios::in);
        file.ignore(32000,'\n');        //ignore 32k chars, or up to '\n'
        file.getline(line,256,'\n');    //take in the next line, up to 256 chars
        std::cout<<line;                //output the line
        std::cin.get();                 //wait for user input
        return 0;
    Last edited by major_small; 03-30-2005 at 09:51 AM. Reason: commentation
    Join is in our Unofficial Cprog IRC channel
    Channel: #Tech

    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Replies: 20
    Last Post: 06-12-2005, 11:53 PM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. Problem reading file
    By winsonlee in forum C Programming
    Replies: 2
    Last Post: 04-23-2004, 06:52 AM

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