MS Visual C++ 6.0 getline function

Sharky Forums


Results 1 to 4 of 4

Thread: MS Visual C++ 6.0 getline function

Threaded View

  1. #1
    Catfish f15e's Avatar
    Join Date
    Mar 2002
    Location
    I live in the south.
    Posts
    114

    MS Visual C++ 6.0 getline function

    I get this error each time I use the getline function. I am using MS Visual C++ 6.0.

    error C2664: 'class std::basic_istream<char,struct std::char_traits<char> > &__thiscall std::basic_istream<char,struct std::char_traits<char> >::getline(char *,int,char)' : cann
    ot convert parameter 1 from 'char' to 'char *'

    Here is a bit of my code. Can you tell me why I am getting these errors? Thanks for the help!!

    #include<iostream>
    #include<iomanip>
    #include<string>
    #include<fstream>

    using namespace std;

    struct BookItems
    {
    char bk_Isbn;
    char bk_Title;
    char bk_Author;
    char bk_Publisher;
    int bk_Pub_Yr;
    double bk_Price;
    int bk_Num_In_Stock;
    };

    const int NUM_BOOKS = 50;
    const int MAX_ISBN_NUMS = 15;
    const int MAX_TITLE_CHARS = 20;
    const int MAX_AUTHOR_CHARS = 15;
    const int MAX_PUBLISHER_CHARS = 20;

    int main()
    {
    ifstream inFile;
    int counter = 0;
    char isbn[MAX_ISBN_NUMS];
    char title[MAX_TITLE_CHARS];
    char author[MAX_AUTHOR_CHARS];
    char publisher[MAX_PUBLISHER_CHARS];
    BookItems bookInfo[NUM_BOOKS] = {' '};

    inFile.open("books.txt");

    inFile.getline(bookInfo[0].bk_Isbn, MAX_ISBN_NUMS, ',');
    for(int i = 0; i < 50 && inFile; i++)
    {
    inFile.getline(bookInfo[i].bk_Title, MAX_TITLE_CHARS, ',');
    inFile.getline(bookInfo[i].bk_Author, MAX_AUTHOR_CHARS, ',');
    inFile.getline(bookInfo[i].bk_Publisher, MAX_PUBLISHER_CHARS, ',');
    inFile >> bookInfo[i].bk_Pub_Yr >> bookInfo[i].bk_Price
    >> bookInfo[i].bk_Num_In_Stock;
    inFile.getline(bookInfo[i+1].bk_Isbn, MAX_ISBN_NUMS, ',');

    cout << bookInfo[i].bk_Title << bookInfo[i].bk_Author << bookInfo[i].bk_Publisher
    << bookInfo[i].bk_Pub_Yr << bookInfo[i].bk_Price << bookInfo[i].bk_Num_In_Stock
    << bookInfo[i+1].bk_Isbn;

    counter++;
    }

    inFile.close();

    return 0;
    }
    Last edited by f15e; 09-16-2002 at 08:26 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •