i'm pretty new and can use some help here is the code and error
[code]
//This is for testing code to see how it works
#include <stdafx.h>
#include <iostream>
using namespace std;
int main ()
{
char name2[40];
double age2;
char r;
char name[20];
double age;
int yes;
int no;
cout <<"what is him/her's name?" << endl;
cin>>name;
cout <<"what is their age?" << endl;
cin>>age;
cout <<"Do you want to enter more data?" << endl;
cin>>r;
if (r == "yes")
goto label1;
if (r == "no")
goto done;
cin.ignore();
cin.get();
label1:
{
cout <<"what is him/her's name?" << endl;
cin>>name2;
cout <<"what is their age?" << endl;
cin>>age2;
goto done;
}
done:
{
cout <<"hi" << endl;
system("pause>nul");
}
}
ERRORS:
code.cpp(23) : error C2446: '==' : no conversion from 'const char *' to 'int'
-----------------------------------------------------------------------------
code.cpp(23) : error C2040: '==' : 'int' differs in levels of indirection from 'const char [4]'
------------------------------------------------------------------------------
code.cpp(25) : error C2446: '==' : no conversion from 'const char *' to 'int'
------------------------------------------------------------------------------
error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]
Your error kind of mentions then comparing a single character to a string of characters and the line number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
char r;
if (r == "yes") //how is 1 character equal to 3 characters?
if (r == "no") //same as the one above
double age; //why is age a double? Someone is 10.234 years old? Seems weird
double age2; //Same as above
//All of these should be avoided
goto label1;
goto done;
label1:
done:
goto done;