[Warning] Passing arg 1 of 'reversed' makes integer from pointer without a cast

This is a discussion on [Warning] Passing arg 1 of 'reversed' makes integer from pointer without a cast within the C Programming forums, part of the General Programming Boards category; I'm not sure what this error means but I know it has something to do with the way I'm passing ...

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

    [Warning] Passing arg 1 of 'reversed' makes integer from pointer without a cast

    I'm not sure what this error means but I know it has something to do with the way I'm passing the string into the function. I'm in my first programming class so forgive me if this is a n00b mistake..

    Code:
    //reverse
    #include <stdio.h>
    #include <string.h>
    
    int reversed (char string1, char string2);
    void swap (int* ptrA, int* ptrB);
    
    int main(){
        char word1[20], word2[20];  
        printf("first word");
        scanf("%s", word1);
        printf("second word");
        scanf("%s", word2);
        
        if (reversed(word1, word2))
           printf("the strings are opposite");
        else printf("the strings are not opposite");
        
        system ("PAUSE");
        return 0 
    }
    
    //Pre: string1 is the name read in from the file. string 2 is the name from the 
    //     customer_type array
    //Post:If string1 is reversed and matches string2 1 is returned, if they don't 
    //     match 0 is returned. 
    int reversed (char string1[], char string2[]) {
         
         int i, len;
         char temp;
         len = strlen(string1);
         
         for (i = 0; i < len/2; i++) {
             swap (&string1[i], &string1[len-i-1]);
         }
         if (!strcmp(string1, string2); 
            return 1;
         else
             return 0;
    }
    
    //Pre: ptrA points to a single character in a string while ptrB points to the 
    //     character equally distant from the center and on the other end of the 
    //     string
    //Post:Swaps the value contained in each of the memoory locations. 
    void swap (int* ptrA, int* ptrB) {
         int temp = *ptrA;
         *ptrA = *ptrB;
         *ptrB = temp;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > int reversed (char string1, char string2);
    does not match
    > int reversed (char string1[], char string2[])
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    note that &string1[i] is pointer to char not pointer to int - this will cause problems with your swap function
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 08-28-2009, 08:49 AM
  2. Replies: 4
    Last Post: 01-27-2009, 02:33 PM
  3. Replies: 2
    Last Post: 05-21-2008, 03:52 PM
  4. Replies: 17
    Last Post: 02-13-2006, 01:19 PM
  5. Replies: 3
    Last Post: 01-14-2002, 12:13 PM

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