By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,514 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,514 IT Pros & Developers. It's quick & easy.

Declaring an 8 bit variable in C

P: 2
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
May 28 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
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:
Expand|Select|Wrap|Line Numbers
  1. int8 index;
  2. T array[...];
  3. T element= array[(int)index];
kind regards,

Jos
May 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.