strcpy()

This is a discussion on strcpy() within the C++ Programming forums, part of the General Programming Boards category; ok here is the deal i made this to test my ability at structs and ended up with another problem ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    57

    strcpy()

    ok here is the deal i made this to test my ability at structs and ended up with another problem but i cant figure it out if some one could help me id appreciate it

    Here is the code:

    #include "stdafx.h"
    #include <stdlib.h>
    #include <iostream.h>
    #include "Dagger.h"




    int main(int argc, char* argv[])
    {

    cout << "ok here we go attemting to store the data into the structure ";
    cout << endl;

    weapon kris;

    strcpy(kris.type. "slashing");

    cout << "hopefully if this worked there should be the right value in here";
    cout << endl;
    cout << kris.type;
    cout << endl;



    return 0;
    }

    and here is the header:

    #ifndef _Dagger_H
    #define _Dagger_H
    struct weapon{
    char type[30];
    char name[30];
    int tohitmod;
    int damage;
    int damagemod;
    };

    #endif

    and yesss I am using MSVC++ before anyone starts grumping and groaning

    Thank You!!
    =@-OmegatronO-@=

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    You don't say exactly what problem you are having, but, to get it to compile, I took out the stdafx.h header, added the string.h header, (for strcpy), and changed the "." to a"," in the strcpy function. Seemed to work then.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    57
    ya i need the #include "StdAfx.h" so i dont get a visual error

    it was the string.h that was giving me the trouble (along with my bad grammar)

    i thought it was stdlib.h for that

    thanks though
    =@-OmegatronO-@=

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A Full Program to analyze.
    By sergioms in forum C Programming
    Replies: 2
    Last Post: 12-30-2008, 08:42 AM
  2. Strcpy
    By Godders_2k in forum C Programming
    Replies: 17
    Last Post: 12-12-2007, 11:34 AM
  3. Where is strcpy() defined? (Can't find in string.h ect)
    By Zero_Point in forum C++ Programming
    Replies: 6
    Last Post: 04-03-2006, 05:14 PM
  4. Question about strcpy
    By Kevinmun in forum C Programming
    Replies: 4
    Last Post: 11-02-2005, 10:00 PM
  5. strcpy
    By Luigi in forum C++ Programming
    Replies: 17
    Last Post: 02-16-2003, 03:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21