Skip to content

Instantly share code, notes, and snippets.

@josejuansanchez
Created September 28, 2015 10:15
Show Gist options
  • Save josejuansanchez/4c4ceae0743a99de141a to your computer and use it in GitHub Desktop.
Save josejuansanchez/4c4ceae0743a99de141a to your computer and use it in GitHub Desktop.
generate_short_values.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc < 4) {
printf("Usage: %s <initial_value> <increment> <#total>\n", argv[0]);
return 1;
}
short initial_value = (short) atoi(argv[1]);
short increment = (short) atoi(argv[2]);
int total = atoi(argv[3]);
FILE *f;
f = fopen("samples.bytes", "wb");
short sample = initial_value;
for(short i=0; i < total; i++) {
fwrite(&sample, sizeof(short), 1, f);
sample = sample + increment;
}
fclose(f);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment