Question:

Fixing Parse error in C++?

by  |  earlier

0 LIKES UnLike

Ok, here's part of the script I'm working on:

// enter the base health of the enemy creature

char type;

cout << "Enter the name of the enemy character type in all lowercase:";

cin >> type;

int health;

// define the type value depending on the creature type

if (type strcmp "monster")

{

int health = nMonster;

}

else

{

if (type strcmp "animal")

{

int health = nAnimal;

}

else

{

if (type strcmp "humanoid")

{

int health = nHumanoid;

}

else

{

if (type strcmp "robot")

{

int health = nRobot;

}

// spawn random number for later use

int randomNumber = rand()%11;

// calculate equation for damage done to health depending on

// attack value

int nBonus = 10 + randomNumber;

// use equation number to determine final enemy health depending

// on relative damage done

int enemyHealth = health - attack+nBonus;

Now, the compiler keeps giving me an error message saying "parse error before string constant" for line "if (type strcmp "monster")"

It also says that at "int enemyHealth = health - attack+nBonus;", the last line, that 'health' and 'attack' are not 'declared for this scope'.

Please help me figure this out! I think these are the last problems...

 Tags:

   Report

1 ANSWERS


  1. Check your curly brackets.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.