Thanks guys, I think it was the "type" that got me into trouble. I also used a function in order to read N first
Code:
int findN(FILE* input)
{
int N;
fscanf(input, "%d", &N);
return(N);
}
In terms or my malloc statement, yes I was trying to allocate memory for my array with 3*N space. How should I do this instead?
Code:
ptr = malloc(N*3*sizeof(double));
Also, my code now works for the input I specified in my original post, but now I want to add a description line to it
Code:
4
description that includes spaces up to 80 characters or less
O -0.906801 0.569837 0.066005
O 0.956585 -0.258900 0.342064
O -0.962633 0.494832 0.380356
O -0.259093 0.292540 0.854958
fscanf will only read to whitespace and I need to read it to a character string but what I tried didn't work...
Code:
char buf[81];
fgets(buf, sizeof buf, input);
printf("Description is %s", buf);
any ideas would be great
Thanks a lot