Question: store different type of value in an 2d array using getline. however, there is an error.. the error message is error: no matching function

store different type of value in an 2d array using getline.

however, there is an error..

the error message is \" error: no matching function for call to getline(std::istream&, double&, char)\"

below is the whole error message..

pj2.cpp: In function int main(): pj2.cpp:37:59: error: no matching function for call to getline(std::istream&, double&, char) pj2.cpp:37:59: note: candidates are: /usr/include/c++/4.6/bits/basic_string.tcc:1070:5: note: template std::basic_istream& std::getline(std::basic_istream&, std::basic_string&, _CharT) /usr/include/c++/4.6/bits/basic_string.h:2734:5: note: template std::basic_istream& std::getline(std::basic_istream&, std::basic_string&),>,>,>,>,>,>

and then below is my codes....

can someone help me to store without error message?

#include #include

using namespace std;

struct data { string name; double area; int population; double dencity; };

int main() { struct data a; a.name; a.area; a.population; a.dencity; string array[ 3 ][ 4 ]; int i, j; for( i = 0; i { for( j = 0; j => { if( j == 1) { getline( cin, a.area, '|' ); array[ i ][ j ] = a.area; } if( j == 3 ) { getline( cin, a.dencity, '|' ); array[ i ][ j ] = a.dencity; } getline( cin, a.name, '|' ); array[ i ][ j ] = a.name; cout } } return 0; }




Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!