I am trying to make a (first) useful program in C. What I'm doing is that I'm trying to convert a binary image file of some strange format output by a CCD interface program (long story) into an ASCII table for further manipulation.
My problem involves reading the file in the first place. I have looked at several tutorials online but when I try to write similar code, it doesn't do what I want it to. So far I'm just trying out reading methods. Here's what I have so far:
#include <stdio.h>
int main(void)
{
FILE *file;
int close;
char in;
char out[11];
int i = 0;
file=fopen("c:\\test\\test.txt", "r");
while( (in = fgetc(file)) != EOF);
{
printf("%c", in);
out[i] = in;
i = ++i;
}
close = fclose(file);
printf("close = %d \n", close);
getchar();
return 0;
}
The program compiles and runs just fine, but it doesn't output anything. "test.txt" looks like this: "1 2 3 a b c", without quotes.
Also, I've seen the construct int x[]
to declare arrays in several tutorials, yet none explain what this means. I understand what x[10] or x[10] [10] means (a size 10 and a size 10 x 10 array, respectively). Finally, does x[10] give an array with elements 0-10 or an array with elements 0-9? I.e., does it give a 10 element array or an array with element 10 as its last element? Edit: Never mind, I just found this out myself.
Sorry for my extreme noobishness, but you've got to start somewhere, right?