charとint
#include <stdlib.h> #include <stdio.h> int main(int argc, char* argv[]) { FILE *fp; char c[5] = { '1', '2', '3', '4', '5' }; if ( (fp = fopen("/tmp/foo", "w")) == NULL ) { exit(EXIT_FAILURE); } fwrite(c, sizeof(char), 5, fp); fclose(fp); exit(EXIT_SUCCESS); }
#include <stdlib.h> #include <stdio.h> int main(int argc, char* argv[]) { FILE *fp; int i[5] = { 1, 2 , 3 , 4 , 5 }; if ( (fp = fopen("/tmp/foo", "w")) == NULL ) { exit(EXIT_FAILURE); } fwrite(i, sizeof(int), 5, fp); fclose(fp); exit(EXIT_SUCCESS); }
ふむ。