doubt in boolean and array

This is a discussion on doubt in boolean and array within the C Programming forums, part of the General Programming Boards category; im trying to convert VB code to c programming In the main function it declared as bool res; and then ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    33

    doubt in boolean and array

    im trying to convert VB code to c programming
    In the main function it declared as
    bool res;
    and then they equate it to function
    res = array(array 1 ,array2);
    is it possible to equate like this

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    I do not think C supports boolean types as primitive type.You have to replace it with an int which will have values 0 and 1

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Since C99 there is a boolean type in stdbool.h.

    Bye, Andreas

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    33
    Or is it possible to write the array function as
    bool array(array1[],array2[])
    res = array(array1,array2);

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,265
    Yes, it is. AndiPersti already gave you a pointer in that direction.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Quote Originally Posted by AndiPersti View Post
    Since C99 there is a boolean type in stdbool.h.

    Bye, Andreas
    Thank you Andreas.I wasn't aware of that.If someone -for some reason- does not want to use this library then we can construct by his own.
    Quote Originally Posted by prathiksa View Post
    Or is it possible to write the array function as
    bool array(array1[],array2[])
    res = array(array1,array2);
    It is possible to have the prototype as
    Code:
    bool array(array1[],array2[]);
    and inside the body of the function to return true,false or a variable which is declared as bool
    (assuming you use the library that Andreas suggested)

  7. #7
    Registered User
    Join Date
    Oct 2012
    Posts
    33
    Thanks

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,265
    Well, the prototype should actually be:
    Code:
    bool array(T1 array1[], T2 array2[]);
    where T1 and T2 are the types of the elements of the respective arrays. You may also need a size parameter for each array since you will only be passing a pointer.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. most efficient way of displaying a *HUGE* boolean array
    By manasij7479 in forum C++ Programming
    Replies: 9
    Last Post: 05-13-2011, 01:05 PM
  2. a Movement doubt in an array
    By louis_mine in forum C Programming
    Replies: 4
    Last Post: 02-03-2005, 09:12 PM
  3. Replies: 4
    Last Post: 04-02-2004, 07:30 PM
  4. Boolean in a character array
    By newy100 in forum C++ Programming
    Replies: 7
    Last Post: 11-29-2003, 01:32 PM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-26-2001, 12:45 AM

Tags for this Thread


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