problem comparing character

This is a discussion on problem comparing character within the C Programming forums, part of the General Programming Boards category; Code: char *compareChar(char *sN, char *sC, char *rC){ int i,j; int destination_len; destination_len = strlen(rC); for(i=0;i<destination_len;i++) { if(*rC == "o") ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    41

    problem comparing character

    Code:
    char *compareChar(char *sN, char *sC, char *rC){
    	int i,j;
    	int destination_len;
    
                    destination_len = strlen(rC);
    
        for(i=0;i<destination_len;i++)
       {	
    	if(*rC == "o")
    	{
    		printf("%c \n",*rC);
    
    	}
           rC++;
       }
    }
    for the above function, i pass in "hello world" to the char *rC. I would like to know why does this warning occurs and also how can i solve this problem ??.

    "warning C4047: '==' : 'int ' differs in levels of indirection from 'char [2]"

  2. #2
    zsaniK Kinasz's Avatar
    Join Date
    Jan 2003
    Posts
    222
    try rc[x] or &rc

    edit: oh and "" means string if you want to compare characters use ' '
    "Assumptions are the mother of all **** ups!"

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,156

    Re: problem comparing character

    Code:
    if(*rC == "o")
    The above line should probably be
    Code:
    if(*rC == 'o')
    And use better formatting. Comments would help too
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with comparing strings!
    By adrian2009 in forum C Programming
    Replies: 2
    Last Post: 02-28-2009, 09:44 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. c++ problem with character manipulation
    By scrapper777 in forum C++ Programming
    Replies: 3
    Last Post: 11-03-2003, 10:48 PM
  4. Problem comparing string from text file with string constant
    By XenoCodex Admin in forum C++ Programming
    Replies: 3
    Last Post: 07-25-2002, 10:17 AM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM

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