strcmp and strcpy error

This is a discussion on strcmp and strcpy error within the C++ Programming forums, part of the General Programming Boards category; hi, I have 3 std::string and I try to use strcmp and strcpy. but for both of them I've got ...

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103

    strcmp and strcpy error

    hi, I have 3 std::string and I try to use strcmp and strcpy. but for both of them I've got this error "cannot convert parameter 1 from 'std::string' to 'const char *'"

    where is the problem?

    I don't know if source code needed or not. so I didn't post it

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by behzad_shabani View Post
    hi, I have 3 std::string and I try to use strcmp and strcpy.
    That's your problem, right there. strcmp and strcpy are not designed for std::strings; the equivalents are == and =, respectively.

  3. #3
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    Quote Originally Posted by tabstop View Post
    That's your problem, right there. strcmp and strcpy are not designed for std::strings; the equivalents are == and =, respectively.
    You mean I should use these?:
    Code:
    string1 = string2 // for copy
    
    if (string1 == string2){
    -----
    -----
    -----
    } // and this for compare?

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    That is what the man said.

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. 2D arrays, strcpy and strcmp Problems
    By Windu102 in forum C Programming
    Replies: 3
    Last Post: 08-23-2008, 02:00 AM
  3. Replies: 7
    Last Post: 06-16-2006, 10:23 PM
  4. help with #define, strcmp, and strcpy
    By doc_watson2007 in forum C Programming
    Replies: 8
    Last Post: 12-20-2004, 10:50 PM
  5. strcpy & strcmp, what is wrong?
    By Silverdream in forum C Programming
    Replies: 7
    Last Post: 02-13-2002, 03:36 PM

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