Thread: strcpy problem

  1. #1
    Registered User
    Join Date
    Sep 2002

    Thumbs down strcpy problem

    I have the following code, and am trying to copy an array of charactes from one variable to another:
    char name[15];
    int age;
    cout << "Name:";
    cin.getline(n, 15);
    cout << "Age:"; cin >> a;
    age = a;
    strcpy(name, n);
    "name" is declared somewhere else in the program, as char[15]..

    The error i'm getting is that "strcpy" is an undeclared identifier.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Northern Virginia/Washington DC Metropolitan Area
    Have you put #include <cstring> at the top of your program?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    Or just write one for fun.

    char * strcpy(char * target, char * source){
    char * index = target; 
     while(*source != 0)       { 
      *(index++) = *(source++);
    *index = 0;
    return target;
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's up with this strcpy?
    By fanoliv in forum C Programming
    Replies: 7
    Last Post: 06-19-2006, 05:24 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. From stream/file to a string array problem
    By dradsws in forum C Programming
    Replies: 2
    Last Post: 10-01-2001, 06:24 PM