Declaring an 8 bit variable in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hemanth Kumar P
    New Member
    • May 2007
    • 2

    Declaring an 8 bit variable in C

    Hello Sir,
    I had declared in type def char as an int8. But while excuting a program, when I had used this as a variable in array subscript, I am getting a warning message of "array subscript has type character". To eradicate this problem any solution?

    Hemanth Kumar P
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by Hemanth Kumar P
    Hello Sir,
    I had declared in type def char as an int8. But while excuting a program, when I had used this as a variable in array subscript, I am getting a warning message of "array subscript has type character". To eradicate this problem any solution?

    Hemanth Kumar P
    Array index values should be ints. If you know what you're doing you should tell
    the compiler so by explictly casting your char to an int:[code=cpp]
    int8 index;
    T array[...];
    T element= array[(int)index];[/code]

    kind regards,

    Jos

    Comment

    Working...