: error C2015: too many characters in constant

it seems after fixing the error i get a new error, i fixed the quotes now i get this

Compiling...
test.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Final\test.cpp(61) : warning C4800: 'char *' : forcing value to bool 'true' or 'false' (performance warning)
C:\Program Files\Microsoft Visual Studio\MyProjects\Final\test.cpp(61) : error C2106: '=' : left operand must be l-value
Error executing cl.exe.

Final.exe - 1 error(s), 1 warning(s)


the errors are always here if( country ="usa" || country ="united stats")
im trying to test the user input which is cin >> country; and test if it is the same is the characters usa or united states, an other words im comparing 2 strings



#include <iostream>
using std::cout;
using std::cin;
using std::endl;
// Functions

char Getprofile(char Fullname);

int Getbirthday(int month,int day,int year);

char Getaddress(char city, char state,char country);

//*****************************************************
int main()
{
cout <<"********************\n";
cout <<"Create Profile\n";

char Getprofile(char Fullname);

int Getbirthday(int month,int day,int year);

char Getaddress(char city, char state, char country);

return 0;
}


//***********************************
char Getprofile(char Fullname)
{
char Firstlastname[60]={'\0'};

cout <<"\nEnter Full name";
cin >> Firstlastname;

return(Fullname);
}
//*********************************

int Getbirthday(int month, int day, int year)
{
cout <<"Enter birthdate in number format i.e 11/28/1983\n";

cout <<"Enter Month: ";
cin >> month;

cout <<"\nEnter day: ";
cin >> day;

cout <<"\nEnter year: ";

return(month,day,year);
}
//******************************************************
char GetAddress(char city, char state, char country)
{
cout <<"\nEnter country";
cin >>country;

if( country ="usa" || country ="united stats")
{

cout <<"GOD Bless AMERICA\n";
cout <<"\nEnter state: ";
cin >> state;

cout <<"\nEnter city: ";
cin >> city;
}
else
{
cout <<"\nEnter City: ";
cin >>city;
}
return (city,state,country);
}
//*********************************************************


Last edited on
It's what the errors say. You're defining your functions inside main(), which is illegal.
Single quotes are for single characters eg: 'a' '\n' '\xdb'
For strings you need double quotes eg: "Hello World"
Last edited on
Why do you edit your first post instead of adding a new one? Using [code][/code] tags would be useful...

You have several errors for that line ( if( country ="usa" || country ="united stats"))
1) conditional 'equal to' operator is ==
2) you are declaring country as a char and you are using it as a char*
3) C strings comparison doesn't work in that way, read http://www.cplusplus.com/reference/clibrary/cstring/strcmp.html
Last edited on
Topic archived. No new replies allowed.