strcpy

This is a discussion on strcpy within the C++ Programming forums, part of the General Programming Boards category; What is the equivalent of strcpy in c++ and do I have to use a .h for it??...

  1. #1
    Unregistered
    Guest

    strcpy

    What is the equivalent of strcpy in c++ and do I have to use a .h for it??

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    >> What is the equivalent of strcpy in c++ and do I have to use a .h for it??

    I'd say strcpy() in string.h

    Some things just don't change.

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,806
    And also std::strcpy() in <cstring> right?
    "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

  4. #4
    Unregistered
    Guest
    I am using a c program with strcpy I want to convert it to c++ but I don't know the code for strcpy in C++

    can anyone help

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    actually, wouldn't this be the equivalent?
    Code:
    str1 = str2;
    where st1 and st2 are std::string ?
    always looking, make an offer. get me out of this place.

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    52
    actually, wouldn't this be the equivalent?

    code:--------------------------------------------------------------------------------
    str1 = str2;
    Only if they're declared as strings and not char*/char[], I think.
    Turn no more aside and brood
    Upon love's bitter mysteries
    For Fergus rules the brazen cars...

  7. #7
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    right, but a lot of people are looking for so-called C++ equivalences so I suppose it could be said that

    char [] == std::string in C++

    I don't really agree. I think C is mostly contained by C++ so I agree with TheDog on that one.

    strcpy() == strcpy() in C++ as C is a rough subset of C++
    always looking, make an offer. get me out of this place.

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, 09:42 AM
  2. Strcpy
    By Godders_2k in forum C Programming
    Replies: 17
    Last Post: 12-12-2007, 12:34 PM
  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, 06:14 PM
  4. Question about strcpy
    By Kevinmun in forum C Programming
    Replies: 4
    Last Post: 11-02-2005, 11:00 PM
  5. strcpy
    By Luigi in forum C++ Programming
    Replies: 17
    Last Post: 02-16-2003, 04:11 PM

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