1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'C' started by LOG, May 22, 2011.

  1. LOG

    LOG New Member

    Joined:
    May 22, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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:)
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    You need to #include the header that defines strcpy, which is string.h.
     

Share This Page