Help with my program

This I can do:
Im doing a project for school and am feeding 6 analog inputs with varying voltages on my Arduino and output its values to display.

It looks like this:
/*

Reading data from Port 0 - 5 and print to screen every 1 second.
Not sure how to store as file yet

*/

int analogPin0 = A0;
int analogPin1 = A1;
int analogPin2 = A2;
int analogPin3 = A3;
int analogPin4 = A4;
int analogPin5 = A5;

int val0 = A0;
int val1 = A1;
int val2 = A2;
int val3 = A3;
int val4 = A4;
int val5 = A5;

void setup()
{
Serial.begin(9600); // setup serial
}

void loop()
{
val0 = analogRead(analogPin0);
Serial.println(val0);
val1 = analogRead(analogPin1);
Serial.println(val1);
val2= analogRead(analogPin2);
Serial.println(val2);
val3 = analogRead(analogPin3);
Serial.println(val3);
val4= analogRead(analogPin4);
Serial.println(val2);
val5 = analogRead(analogPin5);
Serial.println(val3);

delay (1000);
}

I would like to save these values to a file to read them later, say in EXCEL.
I tried this before the last part:

#include < stdio.h>

void main()
{
FILE *fp;
int i;

fp = fopen("foo.dat", "w"); /* open foo.dat for writing */

fprintf(fp, "\nSample Code\n\n"); /* write some info */
for (i = 1; i <= 10 ; i++)
fprintf(fp, "i = %d\n", i);

fclose(fp); /* close the file */
}

But it wont compile. What am I doing wrong? Do I have to create the file first?where?

Where are you trying to store the file?

EriSan500

You can't run 'fopen' etc on an Arduino

Use the serial port to feed the data to your PC and store it on file there or you need to get a SD card reader and write to file onto a SD card.

If you can use a PC .. that is the easy / cheep route .. no extra components needed. If you can not use a PC .. look for a cheep SD card reader like this ...

(I have read and written a file using this product, so I can say it works and provide working code if you can't get it from the samples / links from here and sparkfun).