hi there, i just want to know what data type i need inorder to store a binary word eg. 10010111
Depends on how easy you want to access the bits, and how you get the data.
You could store the data as an unsigned char, and access each bit using masks. That easily handles single bytes.
You could store the values 0 and 1 in an array of char or short int or int, accessing each by array index. This would make dealing with multibyte words more convenient.
thanks..my task was to encode a word that should be entered during runtime and adding parity bits, so if using arrays that means i can't modify its position during runtime...please clarify this if iam on the right track...
Sure you could modify during runtime. And make allowance to store the parity bit(s) as well.
Say you want to store a byte, plus a parity bit. Allocate an array of 9 char's (unsigned, if you want, but you'll only be storing values 0 and 1). Store the byte data to elements 0-7, calculate and store the parity bit in index 8. You'll have full access to the "bits" and be able to modify them as needed.