ok here is the code stripped down to its bare minimum. I have even commented out any of the file manipulation stuff so this shows that its the file pointer itself which isnt working:
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int loop;
int signalOutput;
int flag;
int column1;
float column2;
float temperatureArray[10];
int quit;
srand(time(NULL));
FILE *fp;
printf("\n\n The sensor readings and their corresponding temperatures:\n");
fp = fopen("c:\\LOOKUP.txt", "r");
/*
for(loop=0; loop=10; loop++)
{
signalOutput = (int)(rand()%15);
for(flag=0; flag=1; 0)
{
fscanf(fp, "%i %f",&column1, &column2);
if ( signalOutput > column1 )
{
temperatureArray[loop] = column2;
flag = 1;
printf("\n se %i = %f", signalOutput, temperatureArray[loop]);
}
}
}
*/
fclose(fp);
printf("Press enter to quit");
scanf("%i", &quit);
return 0;
}
content of LOOKUP.txt
0 10
1 12
2 14
3 16
4 18
5 20
6 21
7 22
8 23
9 24
10 24.5
11 25
12 25.25
13 25.5
14 25.75
15 26
run errors from visual studio express:
1>------ Build started: Project: Assignment 3, Configuration: Debug Win32 ------
1> testingarea.c
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(16): warning C4244: 'function' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(18): error C2275: 'FILE' : illegal use of this type as an expression
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(66) : see declaration of 'FILE'
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(18): error C2065: 'fp' : undeclared identifier
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(22): error C2065: 'fp' : undeclared identifier
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(22): warning C4047: '=' : 'int' differs in levels of indirection from 'FILE *'
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(44): error C2065: 'fp' : undeclared identifier
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(44): warning C4047: 'function' : 'FILE *' differs in levels of indirection from 'int'
1>c:\users\david baratheon\documents\visual studio 2010\projects\assignment 3\assignment 3\testingarea.c(44): warning C4024: 'fclose' : different types for formal and actual parameter 1
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========