Skip to content

Instantly share code, notes, and snippets.

@rmccullagh
Created April 9, 2015 18:46
Show Gist options
  • Select an option

  • Save rmccullagh/0ffd679da00af0178da4 to your computer and use it in GitHub Desktop.

Select an option

Save rmccullagh/0ffd679da00af0178da4 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
int main()
{
int r[10];
for(size_t i = 0; i < 10; i++) {
r[i] = i + 1;
}
FILE* fp = fopen("a.dat", "wb");
if(fp == NULL) {
fprintf(stderr, "I/O error\n");
return 1;
}
fwrite(r, sizeof(int), 10, fp);
fclose(fp);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment