/* integer_rep.c Jeff Ondich, 9 Jan 2023, originally named integers.c Modified by Tanya Amert for Fall 2025. How do integers get written to files? Compile as usual: gcc -Wall -Werror -g -o integer_rep integer_rep.c Run with no command-line arguments: ./integer_rep */ #include // Use fwrite and fprintf to output integers int main() { // Write ints with fwrite -- this outputs the actual integer, // not the string representation of it int j = 25; fwrite(&j, sizeof(int), 1, stdout); j = 0xABCDE; fwrite(&j, sizeof(int), 1, stdout); // Write ints with fprintf and the %d format specifier -- // this outputs the string representation, not the actual integer fprintf(stdout, "\t\t\t"); // add some blank space (tabs) fprintf(stdout, "0x%X", j); fprintf(stdout, "\n"); return 0; }