C/C++ pointer type pointing to single bit?
c, c++, pointers
Solution
There no such thing as a bit pointer in C++. You need to use two things, a byte pointer and an offset to the bit. That seems to be what you are getting towards in your code. Here's how you do the individual bit operations.
// set a bit
*ptr |= 1 << index;
// clear a bit
*ptr &= ~(1 << index);
// test a bit
if (*ptr & (1 << index))
...
Problem
I want to modify individual bits of data, (for e.g. `int`s or `char`s). I want to do this by making a pointer, say `ptr`. by assigning it to some int or char, and then after incrementing `ptr` n times, I want to access the nth bit of that data. Something like ``` // If i want to change all the 8 bits in a char variable char c="A"; T *ptr=&c; //T is the data type of pointer I want.. int index=0; for(index;index<8;index++) { *ptr=1; //Something like assigning 1 to the bit pointed by ptr... } ```