so here is my code -- whenever i try to compile it says SYNTAX error

#include <stdio.h>

long FindMaximum(long* numbers, int count)
{
	long max = numbers[0];
	int i;
	for(i = 0; i< count; i++)
	{
		if (numbers[i] > max)
		{
			max = numbers[i];
		}
	}
	return max;
}
long FindMinimum(long* numbers, int count)
{
	long min = numbers[0];
	int i;
    for(i = 0; i< count; i++)
	{
	
	if (numbers[i] < min)
		{
			min = numbers[i];
		}
	}
	return min;
}

float FindAverage(long* numbers, int count)
{
	long sum = 0;
	int i;
    for(i = 0; i< count; i++)
	{
		sum += numbers[i];
	}
	if (sum == 0)
		return 0;
	return sum/(float)count;
}
void ParseFile(char* fileName)
{

	printf("This Program will print the list of numbers in the data, and it’s Max, Min and Avg Values.\n");
	char line[80];
	long number[100];
	int i;
    for(i = 0; i<100;i++)
	{
		number[i] = 0;
	}
	FILE* fr = fopen (fileName, "r");  /* open the file for reading */
	int index = 0;
   while(fgets(line, 80, fr) != NULL)
   {
	 sscanf (line, "%ld", &number[index++]);
	 printf ("%ld\n", number[index-1]);
   }
   printf("The minimum is %ld \n",FindMinimum(number,index));
   printf("The maximum is %ld \n",FindMaximum(number,index));
   printf("The average is %4.2f \n",FindAverage(number,index));
   fclose(fr);  
}

int _tmain(int argc, _TCHAR* argv[])
{
	ParseFile("c:\\justin\\data.txt");
	return 0;
}

here is error:

Compiler: Default compiler
Executing  gcc.exe...
gcc.exe "C:\cygwin\home\Justin\Individual_Project.c" -o "C:\cygwin\home\Justin\Individual_Project.exe"    -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib" 
C:\cygwin\home\Justin\Individual_Project.c:68: error: syntax error before "_TCHAR"

Execution terminated

Can someone tell me what exactly is off?

My bet is that you copied some code from the net that was written with VC++ 2010 Express and you are trying to compile it with gcc???

_TCHAR is a macro defined in tchar.h. You can just replace it with char* so that the line looks like this: int main(int argc, char* argv[])

commented: Thnx - its fixed, +0

Hey man, you guessed right -- now that i fixed this -- i try to run it in Cygwin -- but it comes up _ Segmentaion Fault (Core Dumped)... any idea on what might be wrong here?

I am a total begineer , sir.

what operating system are you running? If *nix then use debugger named gdb and it will tell you where the error was by reading that core file.

Actually - i think it was because i didnot assign the file name of the data set. Now its working (yea i totally copied the code...) hopefully not nect time.. Thnx for your help Ancient Dragon.

If you would add somesort of check if the file you're trying to open actually exist, then you would probably not get this error.

*moved to C

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.