Due tomorrow. Almost done. Couple of q's on some errors.

This is a discussion on Due tomorrow. Almost done. Couple of q's on some errors. within the C Programming forums, part of the General Programming Boards category; Alright, seems my program is running alright. If only I could get some of these errors cleared up. strcpy(temp3, sec[j ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    4

    Due tomorrow. Almost done. Couple of q's on some errors.

    Alright, seems my program is running alright. If only I could get some of these errors cleared up.

    strcpy(temp3, sec[j - 1];
    strcpy(sec[j - 1], sec[j]);
    strcpy(sec[j], temp3);

    cannot convert int to const char *
    type mismatch in parameter
    mismatch in call

    I don't have const written in my call or my function declaration or in the actual function. So why would this be. I did have const everywhere but I deleted it. If I were to copy the program and rename it would it then work? If so does anyone know why this occurs?

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    * What is temp3 defined as?
    * What is sec defined as?

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    4
    char sec[MAX_COL]
    temp is what I am using to sort sec

  4. #4
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149
    I assume you mean that temp3 is just a standard char:
    Code:
    char temp3;
    If you are trying to manipulate the individual charaters in an array of char's then you must treat them as individual char's. Simple assignment should be used here, not strcpy.
    Code:
    temp3 = sec[j - 1]; 
    sec[j - 1] = sec[j]; 
    sec[j] = temp3;
    David
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

  5. #5
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    david's right, when you want to put a string onto another strcpy() is what you need, but to just assign a particular value from that array, an equals sign is all you need.

  6. #6
    Unregistered
    Guest
    Thanks guys. This has been some of the best help I have gotten online.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 01:54 AM
  2. Help with a couple compiler errors
    By s_ny33 in forum C Programming
    Replies: 1
    Last Post: 09-15-2005, 08:46 PM
  3. Couple of Q's.....
    By oobootsy1 in forum C++ Programming
    Replies: 18
    Last Post: 02-23-2004, 01:03 PM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 12:43 PM

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