Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4E2BB4766A7 for ; Tue, 10 Dec 2002 09:45:21 -0500 (EST) Received: from avalon.informatik.uni-freiburg.de (avalon.informatik.uni-freiburg.de [132.230.150.1]) by postgresql.org (Postfix) with ESMTP id DA3F5475F23 for ; Tue, 10 Dec 2002 09:44:52 -0500 (EST) Received: from zechine.informatik.uni-freiburg.de (mail@zechine.informatik.uni-freiburg.de [132.230.167.47]) by avalon.informatik.uni-freiburg.de (8.9.0/8.9.0) with ESMTP id PAA14361 for ; Tue, 10 Dec 2002 15:44:56 +0100 (MET) Received: from localhost ([127.0.0.1] helo=informatik.uni-freiburg.de ident=guntha) by zechine.informatik.uni-freiburg.de with esmtp (Exim 3.35 #1 (Debian)) id 18Llcz-0008JR-00 for ; Tue, 10 Dec 2002 15:44:53 +0100 Message-ID: <3DF5FDE5.EB89D6CD@informatik.uni-freiburg.de> Date: Tue, 10 Dec 2002 15:44:53 +0100 From: Aravind Babu Guntha X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.19-k7-4gb i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: problem compiling c-functions Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/147 X-Sequence-Number: 6642 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 #include /* 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