compare with chars && compare with int

This is a discussion on compare with chars && compare with int within the C Programming forums, part of the General Programming Boards category; my code is as follows: Code: int a = 0; int b = 1; char a = 'T'; char b ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    168

    compare with chars && compare with int

    my code is as follows:
    Code:
    int a = 0;
    int b = 1;
    char a = 'T';
    char b = 'A';
    if ( a != b ) { 
        //do
    }else 
    {
       //do other
    }
    
    if ( a != b ) 
    {
        //do
    } else
    {
       //do other
    }
    which compare is faster?
    char compare or int compare?
    I have thought 'char compare' is faster.
    because char is 8bit,and int is 16bit. isn't it?

    if a b are array, what happens?
    Code:
    char a[] = "abcddddd";
    char b[] = "dddddddd";
    Last edited by zcrself; 04-22-2010 at 04:02 AM.

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    I'm having a deja-vu.
    which data structure is faster ?

    The answer to this is EXACTLY the same.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 09:36 PM
  2. Replies: 3
    Last Post: 05-13-2007, 09:55 AM
  3. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 10:16 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 06:20 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM

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