ANSI C Tulis pendek tanpa tanda untuk mengajukan
int write_obj_file (char* filename, unsigned short int program_bin[ROWS] ){
FILE *fptr = fopen(filename, "wb");
if (fptr == NULL)
return -1;
unsigned short int code = 0xABCD;
if (fwrite(&code, sizeof(code), 1, fptr) < 1) {
fclose(fptr);
return -1;
}
unsigned short int code2 = 0x0000;
if (fwrite(&code2, sizeof(code2), 1, fptr) {
fclose(fptr);
return -1;
}
unsigned short int code3 = 0x0001;
if (fwrite(&code3, sizeof(code3), 1, fptr) {
fclose(fptr);
return -1;
}
unsigned short int code4 = 0x1101;
if (fwrite(&code4, sizeof(code4), 1, fptr) {
fclose(fptr);
return -1;
}
fclose(fptr);
return 0;
}
Michael Mainbird