AHHHHH! I give up. How do I convert a strings of ones and zeros into a byte that I can write to a binary file??? I've tried everything I can think of. Here is what i have so far:

Code:
    string val = "01000001"; //Binary for letter 'A'
    unsigned char a = 00000000;
    //cout << a << endl;
    unsigned char MASK = 1 << 0;
    //cout << MASK << endl;
    
    for (int i = val.size()-1; i >= 0; i--) {
        a <<= 1;
        if(val.substr(i,i+1)=="1"){
            a |= MASK;
        }
    }
    cout << a << endl;
fyi i want to write the file like this, so i need it in char arrays.

char * output; //load data, etc. etc.
writeFile(output, length, "output.txt");