Skip to content

Instantly share code, notes, and snippets.

@spiros
Created February 16, 2017 00:22
Show Gist options
  • Save spiros/593136d724c16d67d76f62df5f751129 to your computer and use it in GitHub Desktop.
Save spiros/593136d724c16d67d76f62df5f751129 to your computer and use it in GitHub Desktop.
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "Q93_qrisk2_2015_0.h"
#include "Q93_qrisk2_2015_1.h"
int main() {
char input[100];
const char delims[] = ",";
scanf("%s", input);
const char *s = input;
int i=0;
int input_sex;
do {
size_t field_len = strcspn(s, delims);
printf("%d: \"%.*s\"\n", i, (int)field_len, s);
if ( i == 1 ) {
input_sex = (int)s;
}
s += field_len;
i++;
} while (*s++);
printf("Sex: %d\n", input_sex);
exit(0);
}
@spiros
Copy link
Author

spiros commented Feb 16, 2017

tuna:QRISK2-2015-lgpl-source spiros$ echo "1,2,3,4,5" | ./qr2
0: "1"
1: "2"
2: "3"
3: "4"
4: "5"
Sex: 1569425938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment