'How can i write x00 in file.bin c++ ofstream::write

The problem is that i can't initialize the INODE->NAME is behaving unexpected. In the column 0B the result is FF, but i want 00. What i am doing wrong? What a really want is to write a value that is smaller than sizeof(INODE[i].NAME), but the bytes that i did not fill with the value should be 00 and not random!

typedef struct {
    unsigned char IS_USED;             
    unsigned char IS_DIR;              
    char NAME[10];                     
    char SIZE;                         
    unsigned char DIRECT_BLOCKS[3];    
    unsigned char INDIRECT_BLOCKS[3];
    unsigned char DOUBLE_INDIRECT_BLOCKS[3];
} INODE;
ofstream fileSystem(fsFileName, ios::out | ios::binary);

// in this case numblocks is 1

// Writing INODES
    for (int i = 0; i < numBlocks; i++) {
        char empty[] = {'/', '\x00'};
        if (i == 0) {
            cout << sizeof(empty) << endl;
            strcpy(node[i].NAME, empty);
            node[i].IS_USED = 0x01;
            node[i].IS_DIR = 0x01;
        } else {
            strcpy(node[i].NAME, "\x00\x00\x00\x00\x00\x00\x00\x00");
            node[i].IS_USED = 0x00;
            node[i].IS_DIR = 0x00;
        }
        node[i].SIZE = 0x00;
        node[i].DIRECT_BLOCKS[0] = 0x00;
        node[i].DIRECT_BLOCKS[1] = 0x00;
        node[i].DIRECT_BLOCKS[2] = 0x00;
        node[i].INDIRECT_BLOCKS[0] = 0x00;
        node[i].INDIRECT_BLOCKS[1] = 0x00;
        node[i].INDIRECT_BLOCKS[2] = 0x00;
        node[i].DOUBLE_INDIRECT_BLOCKS[0] = 0x00;
        node[i].DOUBLE_INDIRECT_BLOCKS[1] = 0x00;
        node[i].DOUBLE_INDIRECT_BLOCKS[2] = 0x00;
        fileSystem.write(reinterpret_cast<const char*>(&node[i]), sizeof(INODE));
    }

This is my file.bin

This is my file.bin



Solution 1:[1]

In the soap world, you'll want to think of the CustomField as the superclass for a number of specialized classes like TransactionBodyCustomField or EntityCustomField. From there, you can access the record using a standard get call. I'm not familiar with the java-proxies, but in python, we'd do something like:

f = soap.get('transactionBodyCustomField', '30')

which would send an xml body with the appropriate recordRef xml.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 2ps