getline problem

This is a discussion on getline problem within the C++ Programming forums, part of the General Programming Boards category; when i have getline(ifIn, strFile); in my program does it require imput from the user. if in is my ifstream ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    20

    getline problem

    when i have getline(ifIn, strFile); in my program does it require imput from the user.

    if in is my ifstream
    strFile is my string i am reading the file into

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    no.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    what is wrong with this: (when i run my program it gets to the while loop and stops, it stays in the program but doesn't do anything)

    [code]

    while (!ifIn.eof()); // I think the problem is here
    {
    int i=0;

    //-------then rest of code---------

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    well what exactly are you trying to do? input into a char? string array?

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    input into a string array

  6. #6
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Read the FAQ about eof() and feof() etc.

    While loops look like this...

    Code:
    while (condition_true)
    { // do this}
    not
    Code:
    while (condition_true);
    {// cant get here}
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 06:20 AM
  2. Words and lines count problem
    By emo in forum C Programming
    Replies: 1
    Last Post: 07-12-2005, 04:36 PM
  3. getline() problem
    By mrafcho001 in forum C++ Programming
    Replies: 5
    Last Post: 06-12-2005, 02:16 AM
  4. Need help with structures
    By yoursport in forum C++ Programming
    Replies: 8
    Last Post: 04-20-2005, 12:59 PM
  5. getline help
    By ProjectsProject in forum C++ Programming
    Replies: 3
    Last Post: 06-14-2004, 12:12 PM

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