Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Help me. I'm kinda new with c++ and I'm trying to build a simple AI program.
This is my code below. I am running it with Dev c++ and I got this [Error] expected unqualified-id before else.

can someone help?

What I have tried:

#include <iostream>
#include <cstring>

using namespace std;

int main()
{
  char str[50];
  here:cin>>str;
  
  if(strcasecmp ("hello",str)==0)
  cout<< "Doing good?";
goto here;
}

 else if(!strcasecmp ("hi",str)){
 {
cout<<"hey there what's your name"<<end1;
goto here;
return 0;
Posted
Updated 15-Jul-18 23:02pm
v2

the posted code is missing a open curly bracket {

C++
if(strcasecmp ("hello",str)==0) {
    cout<< "Doing good?";
    goto here;
 }
 
Share this answer
 
Comments
AnnoyingPig 15-Jul-18 15:17pm    
where to put???? @Bryian Tan. Master.
Thank you for reply.
Bryian Tan 15-Jul-18 15:20pm    
This line
if(strcasecmp ("hello",str)==0)
to
if(strcasecmp ("hello",str)==0) {
AnnoyingPig 15-Jul-18 15:32pm    
@Bryian Tan. Master sir. I Got it right Thank you so much!
You really SHOULDNT use the goto command, because it is deprecated style.

So remove the statement and write the need code or a function call at this place.
 
Share this answer
 
Comments
AnnoyingPig 16-Jul-18 8:48am    
Thank you for helping. @KarstenK sir What are samples for function call?
jeron1 16-Jul-18 10:55am    
Here is but one of many links.
C++ Functions[^]
AnnoyingPig 19-Jul-18 4:30am    
okay. Thank you sir. @jeron1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900