Thread: Error with strcpy and strcat

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    32

    Question Error with strcpy and strcat

    All im trying to do is add a string to strcpy and concatenate with a short. But i am getting two error doing this the code is below

    Code:
     
    
    struct local_stack_def
      {
    
       char *result;
       char delims[3];
       char user_id_E[200];
       short user_maxlen, range_eulm, imp_eulm, len_eulm;
       char msg_eulm[400];
       /*MORE VARIABLE REMOVED TO SHORTEN LENGTH*/
      };
     
      short  pool_err;
      struct local_stack_def *l;
    
    
      l  = POOL_GETSPACE_(i_exit_cb->Pool_addr,sizeof(struct local_stack_def),&pool_err );
    
    
        /*MORE VARIABLE REMOVED TO SHORTEN LENGTH*/
    
      if (l->resultFR != 0)
         {
          l->range_eulm= 1501;
          strcpy(l->msg_eulm,"FILENAME_RESOLVE_ ERROR - ERROR#:");
          strcat(l->msg_eulm, l->resultFR);
    With the strcpy and strcat i get these errors

    Code:
     strcpy(l->msg_eulm,"FILENAME_RESOLVE_ ERROR - ERROR#:");     
    Warning 207: address pointing at code space is taken
    
     strcat(l->msg_eulm, l->resultFR);
         Warning 86: argument 2 conflicts with formal definition

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    344
    The second warning is telling you that resultFR is not a char pointer.

    Not sure about the first one, but then again POOL_GETSPACE_ isn't standard C so it's probably related to that. The docs for your compiler say this about the message :

    "The address of an object that resides in code space is taken. Use of this address is
    valid only within the same code segment as the object."

    Hopefully that means more to you than it does to me :/

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Look into using sprintf() instead of strcpy() and strcat() ... neither can add a number to the end of a string without conversion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem in my strcpy strcat function
    By genie in forum C Programming
    Replies: 7
    Last Post: 11-07-2008, 09:36 AM
  2. Replies: 2
    Last Post: 06-03-2008, 12:57 AM
  3. strcpy() and strcat()
    By Moony in forum C Programming
    Replies: 5
    Last Post: 07-03-2006, 01:18 AM
  4. strcat - strcpy
    By pizzas in forum C Programming
    Replies: 4
    Last Post: 08-05-2003, 02:11 AM
  5. strcat or strcpy?
    By dirgni in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2002, 12:10 PM