Thread: compare with chars && compare with int

  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 03: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, 08:36 PM
  2. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  3. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM