Currently writing a program that opens a file, moves to the given offset & then change the bytes at the offset.
This is the code:
void write(int offset, int modifiedBytes) {
    fstream Binary("path/to/file");
    if(!Binary) {
        cout << "File not found!";
    }
    Binary.seekg(offset); //Go to given position from the given binary file
    Binary.write((char *)&modifiedBytes,4); //put modified bytes into the given position from above
}
and then I have a separate function to add multiply things to it if I want:
void doInjection() {
    write(0xfe,0x7047); //write 7047 to 0xfe
}
although it does write to the given file, it writes 7047 in reverse (4770).
I've also tried to use put(); instead of write, but that allowed me the only use 2 bytes, but it didn't write in reverse.
Anyone has any idea why it's writing my given value in reverse?
 
    