GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


A Paste by taby
1
 
#include <iostream>
using std::cout;
using std::endl;

#include <vector>
using std::vector;

int main(void)
{
    size_t buf_size = sizeof(long unsigned int);

    vector<char> buffer;
    buffer.reserve(buf_size);
    buffer.resize(buf_size);

    long unsigned int x = 2863311530; // 10101010101010101010101010101010 binary

    char *peeker = reinterpret_cast<char *>(&x);

    for(size_t i = 0; i < sizeof(long unsigned int); i++)
    {
        buffer[i] = *peeker;
        peeker++;
    }


//    send(&buffer[0], buffer.size());

    x = 0;

//    recv(&buffer[0], read_size);


    peeker = reinterpret_cast<char *>(&x);

    for(size_t i = 0; i < sizeof(long unsigned int); i++)
    {
        *peeker = buffer[sizeof(long unsigned int) - 1 - i];
        peeker++;
    }

    cout << x << endl;

    return 0;
}