Created
August 16, 2011 05:03
-
-
Save uranusjr/1148469 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define VALUES_PER_LINE 4 | |
#define VALUE_LINES 2 | |
char dataSource[] = "2.315 3.164 9.121 6.148\n2.134 93.124 12.313 1.264"; | |
int main() | |
{ | |
double *values = malloc(VALUES_PER_LINE * VALUE_LINES * sizeof(double)); | |
int i; | |
for (i = 0; i < 2; i++) | |
{ | |
sscanf(dataSource, | |
"%lf %lf %lf %lf ", &values[VALUES_PER_LINE * i], | |
&values[VALUES_PER_LINE * i + 1], | |
&values[VALUES_PER_LINE * i + 2], | |
&values[VALUES_PER_LINE * i + 3]); | |
} | |
for (i = 0; i < VALUES_PER_LINE * VALUE_LINES; i++) | |
printf("values[%d] = %.3lf\n", i, values[i]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment