problem compiling c-functions

From: Aravind Babu Guntha <guntha(at)informatik(dot)uni-freiburg(dot)de>
To: pgsql-admin(at)postgresql(dot)org
Subject: problem compiling c-functions
Date: 2002-12-10 14:44:53
Message-ID: 3DF5FDE5.EB89D6CD@informatik.uni-freiburg.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


i am trying to compile the below c-program.but iam getting the errors as

/usr/lib/crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status

#include <stdio.h>
#include <stdlib.h> /* required for atoi */

int main() {
char c[10];
int sum = 0;
FILE *file;

file = fopen("numbers3.txt", "r");

if(file==NULL) {
printf("Error: can't open file.\n");
return 1;
}
else {
printf("File opened successfully.\n");

while(fgets(c, 10, file)!=NULL) {
sum += atoi(c); /* convert string to int then add it to sum */
}

printf("Now closing file...\n");
fclose(file);
printf("The sum of the numbers is: %d\n", sum);
return 0;
}
}

could anyone please help me in solving this problem

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message UltraMax 2002-12-10 14:56:10 ksqo
Previous Message Oleg Bartunov 2002-12-10 13:37:43 Re: contrib/tsearch crashing postgresql 7.3 Stable