Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   syntax error- 'strcpy' was not declared in this scope (http://www.go4expert.com/forums/syntax-error-strcpy-declared-scope-t25863/)

LOG 22May2011 22:57

syntax error- 'strcpy' was not declared in this scope
 
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:)

xpi0t0s 23May2011 15:01

Re: syntax error- 'strcpy' was not declared in this scope
 
You need to #include the header that defines strcpy, which is string.h.


All times are GMT +5.5. The time now is 20:41.