syntax error- 'strcpy' was not declared in this scope

LOG's Avatar, Join Date: May 2011
LOG
Newbie Member
I am getting an error while compiling, saying that strcpy is not declared in the scope. This segment is the definitions for monsters in a text adventure.

Code:
void initializeMonsters()
{
    // old elk
    monsterArray[0].strength = 10;
    monsterArray[0].dexterity = 10;
    monsterArray[0].hp = 10;
    strcpy(monsterArray[0].name, "Old Elk");
    // Archer
    monsterArray[1].strength = 15;
    monsterArray[1].dexterity = 20;
    monsterArray[1].hp = 15;
    strcpy(monsterArray[0].name, "Archer");
    // Dreadful Skeleton
    monsterArray[2].strength = 20;
    monsterArray[2].dexterity = 10;
    monsterArray[2].hp = 25;
    strcpy(monsterArray[0].name, "Dreadful Skeleton");
    // Ug'lor
    monsterArray[3].strength = 25;
    monsterArray[3].dexterity = 25;
    monsterArray[3].hp = 60;
    strcpy(monsterArray[0].name, "Ug'lor");
    // Graldo >>Fight Before Ga'rados<<
    monsterArray[4].strength = 40;
    monsterArray[4].dexterity = 45;
    monsterArray[4].hp = 60;
    strcpy(monsterArray[0].name, "Graldo");
    // Ga'Rados >>boss<<
    monsterArray[5].strength = 95;
    monsterArray[5].dexterity = 115;
    monsterArray[5].hp = 90;
    strcpy(monsterArray[5].name, "Ga'rados");
}
The declarations that I made are:
Code:
#include <iostream>
#include<ctime>
#include<cstdlib>
#include<cctype>
using namespace std;
I do not understand what I am doing wrong.

Any help is appreciated.

Thanks,
LOG
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
You need to #include the header that defines strcpy, which is string.h.