User User - 17 days ago 6
C Question

How to set a particular byte in a file to 0 or 1?

I have a

char*
to where I want to set the byte, from malloc. How do I set it to 1 or 0, for example?

Answer

Assign to your dereferenced pointer:

//This will (obviously) set it to 1
*your_pointer = 1;

//This will set it to 0
*your_pointer = 0;
Comments