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?
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" );