Incompatible types in assignment

Hi guys, i am newbie in c++, i received an error which is indicated in the title of this thread, can someone help me? Thanks

here is my code


<code>

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<math.h>


int main(void){


char sdname[32];
int yearcode;
char yearname[32];
int number_units;
double downpayment, balance, tuition_fee;
double rate_unit;

cout << "\n\n ";

cout << " \nPlease Enter your good name : ";
gets(sdname);

cout << " \nPlease Enter the year code : ";
cin >> yearcode;

cout << " \nPlease the number of units enrolled : ";
cin >> number_units;

switch(yearcode)
{

case 1 :

yearname = "Freshmen";
rate_unit = 400.00;
break;

case 2 :

yearname = "Sophomore";
rate_unit = 350.00;
break;

case 3 :

yearname = "Junior";
rate_unit = 300.00;
break;


case 4 :

yearname = "Senior";
rate_unit = 280.00;
break;

case 5 :

yearname = "Senior";
rate_unit = 280.00;
break;

}

if(number_units < 10) {

downpayment = 1000.00;



} else if(number_units < 16) {

downpayment = 1000.00;


} else if(number_units < 22) {

downpayment = 2000.00;



}else {

downpayment = 2500.00;


}

tuition_fee = number_units * rate_unit;
balance = tuition_fee - downpayment;

cout << "\n\n\t\t ";

cout << "\nStudent Name :"<< sdname;
cout << "\nYear Name :"<< yearname;
cout << "\nNumber Of Units :"<< number_units;
cout << "\nTuition Fee :"<< tuition_fee;
cout << "\nDown payment :"<< downpayment;
cout << "\nBalance :"<< balance;



cout << "\n\n ";

system("PAUSE");
return(0);

}

</code>
Please change <></> to [][/] :)
But, what is your error?
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<math.h>


int main(void){


char sdname[32];
int yearcode;
char yearname[32];
int number_units;
double downpayment, balance, tuition_fee;
double rate_unit;

cout << "\n\n ";

cout << " \nPlease Enter your good name : ";
gets(sdname);

cout << " \nPlease Enter the year code : ";
cin >> yearcode;

cout << " \nPlease the number of units enrolled : ";
cin >> number_units;

switch(yearcode)
{

case 1 :

yearname = "Freshmen";
rate_unit = 400.00;
break;

case 2 :

yearname = "Sophomore";
rate_unit = 350.00;
break;

case 3 :

yearname = "Junior";
rate_unit = 300.00;
break;


case 4 :

yearname = "Senior";
rate_unit = 280.00;
break;

case 5 :

yearname = "Senior";
rate_unit = 280.00;
break;

}

if(number_units < 10) {

downpayment = 1000.00;



} else if(number_units < 16) {

downpayment = 1000.00;


} else if(number_units < 22) {

downpayment = 2000.00;



}else {

downpayment = 2500.00;


}

tuition_fee = number_units * rate_unit;
balance = tuition_fee - downpayment;

cout << "\n\n\t\t ";

cout << "\nStudent Name :"<< sdname;
cout << "\nYear Name :"<< yearname;
cout << "\nNumber Of Units :"<< number_units;
cout << "\nTuition Fee :"<< tuition_fee;
cout << "\nDown payment :"<< downpayment;
cout << "\nBalance :"<< balance;



cout << "\n\n ";

system("PAUSE");
return(0);

}


Okay, now we can check it.
You may not perform assignments of arrays. So this code

yearname = "Freshmen";

is invalid.

Instead of it you should use standard C function strcpy declared in <cstring>. For example

strcpy( yearname, "Freshmen" );
Topic archived. No new replies allowed.