Skip to content

Instantly share code, notes, and snippets.

@iagox86
Created February 24, 2012 19:29
Show Gist options
  • Save iagox86/1903152 to your computer and use it in GitHub Desktop.
Save iagox86/1903152 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
int main()
{
FILE *f = fopen("test.txt", "r");
double array[3][10000];
char line[1024];
char *token;
int i, j, k, l;
i = 0;
while(fgets(line, 1024, f))
{
j = 0;
for(token = strtok(line, ","); token != NULL; token = strtok(NULL, ","))
{
array[j++][i] = atof(token);
}
i++;
}
for(k = 0; k < i; k++)
{
for(l = 0; l < 3; l++)
{
printf("%f ", array[l][k]);
}
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment