simple structure problem

There's only one problem in compiling conversion from int to non-scalar type phone requested

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <conio.h>
#include <math.h>
#include <iomanip>//sorry don't mind i added many libraries just for fun
#include <string>   
#include <cstdlib>
using namespace std;
/*       */
struct phone{
	int ncode;
	int acode;
	long number;
	
	
};


int main(){
phone p1,p2=(92,41,9235);
cout <<"enter national code";
cin>>p1.ncode;
cout <<"enter area code";
cin>>p1.acode;
cout<<"enter number \n";
cin>>p1.number;
cout << "phone number = + \n";
cout <<p1.ncode<<"-"<<p1.acode<<"-"<<p1.number;
cout <<"phone number 2 = + \n";
cout <<p2.ncode<<"-"<<p2.acode<<"-"<<p2.number;
		
	

	return 0;
	
}
Last edited on
in line 19
 
        phone p1,p2={92,41,9235}; //or p2{92,41,9235}; 
Yes absolutely line 19 has some problem I don't know
thats not the way in which you assign the values to struct

http://www.cplusplus.com/doc/tutorial/structures/
this question is from a renowned book but a compiling error as i stated at top
Line 19: Use braces, not parens.

 
phone p1,p2={92,41,9235};

oh great that worked i was mistaken Thanks to @brown ogum and @ AbstractionAnon
Topic archived. No new replies allowed.