Thread: Can't resolve strcat

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    100

    Can't resolve strcat

    I searched these forums and found many results for "strcat", and have been reading through them. However, after implementing what I have learned, I still can't get rid of this one warning message:

    [Warning] passing arg 2 of `strcat' makes pointer from integer without a cast
    Here is my code:

    Code:
    int mm;
    int input_length;
    char current_char;
    char *corrected_char = malloc(80); // user input without ">"
    input_length = strlen(aa[ii]);
    input_length = (int) input_length - 1;
    
    
    for(mm = 1; mm < input_length; mm++) {
            current_char = aa[ii][mm];
            printf("Character: %c\n", current_char);
            strcat(corrected_char, current_char);
            printf("New char: %c\n", *corrected_char);
                        
    }
    ii++;
    aa[ii] has a maximum size of 80 bytes. Each line in aa[ii] is something like ">hello" or any string, but it always begins with ">". What I am trying to do is strip the ">" and resave the string to a new variable, which would just contain "hello". Everything is working fine except for strcat(). I've tried making current_char a pointer but it doesn't work. Any ideas?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Each line in aa[ii] is something like ">hello" or any string, but it always begins with ">".
    Well what you could do is just:
    Code:
    strcpy(corrected_char, aa[ii]+1);
    Or if the line had some spaces at the beginning before the >, search for the >, then use that as the index:
    Code:
    strcpy(corrected_char, aa[ii]+index);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An interesting question about strcat
    By meili100 in forum C++ Programming
    Replies: 3
    Last Post: 07-07-2009, 12:59 PM
  2. argv change
    By dracayr in forum C Programming
    Replies: 9
    Last Post: 04-10-2009, 02:49 AM
  3. strcat and a char
    By jjacobweston in forum C++ Programming
    Replies: 2
    Last Post: 05-09-2005, 04:10 PM
  4. strcat makes program crash
    By imoy in forum C++ Programming
    Replies: 4
    Last Post: 05-09-2002, 02:41 PM
  5. Removing 'strcat' ed string.
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 11-14-2001, 12:09 AM