Search
 
SCRIPT & CODE EXAMPLE
 

C

ansi c write unsigned short to file

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;
}
Comment

PREVIOUS NEXT
Code Example
C :: main prototype 
C :: Fibonacci program c pthread 
C :: Talk about the difference between call by reference and call by value and in C language with example? 
C :: C #if, #elif and #else Directive 
C :: Combine two sentences into one langage c 
C :: send an array through a pipe 
C :: C static libraries (creating object files) 
C :: ejemplo c holamundo 
C :: code_art_bcm_10.c 
C :: code to reverse the words in a sentnce 
C :: disable gnu++11 option 
C :: compil cywin cgi 
C :: Writing tests for API requests 
C :: uri/beecrowd problem no - 1133 solution in C 
C :: c byte vs char 
C :: BEE/URI problem no 1181 solution in C 
C :: sue murry 
C :: [4,5,6] 
C :: openinh VCL file for Vivado HLS 
C :: how to use arry 
C :: c addition 
C :: c printf float value 
C :: how to get value of multidimensional array in c 
C :: CODE SOURCE POUR LISTE DOUBLEMENT CHAINEé en c 
Dart :: underline text in flutter 
Dart :: Waiting for another flutter command to release the startup lock... 
Dart :: italic text flutter 
Dart :: how to get value from user in dart 
Dart :: flutter substring 
Dart :: Flutter turn string to int 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =