C programming help ....
Collins Richey
crichey at gmail.com
Sun Aug 23 14:06:57 PDT 2009
On Sun, Aug 23, 2009 at 2:49 PM, Ben Duncan<bend at linux4ms.net> wrote:
> Ok, i have a question for the MORE advanced C programmers.
>
> I want to loop thru a string of characters that may contain some
> "high values", i.e. 0xFF and possible use the & function to test that.
>
> Lets say "^" represents the HIGH value mark and the string looks like this:
>
> ABCDEFG^THIS IS A LONG STRING OF DATA^MORE DATA HERE^1234567890^EOF
> STRING^\0"
>
> I want to be able to do something like this:
>
> int idx ;
> char MyString [256] ; /* See above string */
>
> for ( idx = 0 ; idx < strlen (MyString) ; idx++
> {
> if ( Mystring[idx} & 0xFF )
> printf ("High value found at: %i ", idx)
> }
>
>
> Is this the correct way to do this ?
>
Than will return true if any bits are set. Use 0x80 to check only the
leftmost bit.
--
Collins Richey
If you fill your heart with regrets of yesterday and the worries
of tomorrow, you have no today to be thankful for.
More information about the Linux-users
mailing list