gcc 4.5.1 c89
I have a buffer filled with char characters. I need to compare them:
This is an example of the contents of a buffer:
vote buffer [ 51 ] vote buffer [ 32 ] vote buffer [ 49 ] vote buffer [ 32 ] vote buffer [ 50 ] vote buffer [ 32 ] vote buffer [ 53 ] vote buffer [ 32 ]
I am trying to get the int-equivalent of these char, which are in the buffer for comparison.
#define NUMBER_OF_CANDIDATES 7 if((vote_data.vote_buff[i] > NUMBER_OF_CANDIDATES || vote_data.vote_buff[i] < 1) { }
As you can see, this will never be true in the if statement, since the range is much larger.
I tried casting (int). However, this did not solve the problem.
I think I could calculate ascii from the character set. However, I would prefer not to add more complexity if I cannot help.
Thanks so much for any advice,
source share