1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem infile.get(c)

  1. Oct 10, 2012 #1
    1. The problem statement, all variables and given/known data

    I am working in visual 2008 c++ ... The is an errors on error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem &)' : cannot convert parameter 1 from 'char [20]' to 'char &'


    2. Relevant equations



    3. The attempt at a solution

    Code (Text):



    #include "stdafx.h"


    // Assignment I files.cpp : Defines the entry point for the console application.
    //


    #include<iostream>
    #include<fstream>
    #include<string>
    using namespace std;
    struct person
    {
        char name[20];
        int id;
    };

    void main()
    {
    //3.
    char c[20];
    int y;
    ifstream infile("person.txt");
    for(int i=0;i<5;i++)
    {
    infile>>c>>y;
    cout<<c<<"  "<<y<<endl;
    }
    //4.
    infile.seekg(8L,ios::beg);
        infile>>c>>y;
        cout<<c<<"  "<<y;
        while(infile.peek()!=EOF)
        {
            infile.get(c);
            cout<<c;
        }
        infile.close();

       

    }

     
     
  2. jcsd
  3. Oct 10, 2012 #2

    Mark44

    Staff: Mentor

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Problem infile.get(c)
  1. C++ problems (Replies: 12)

  2. C++ Problem (Replies: 6)

  3. C++ problem (Replies: 3)

Loading...