From: Aravind Babu Guntha <guntha@informatik.uni-freiburg.de>
To: pgsql-admin@postgresql.org
Subject: problem compiling c-functions
Date: Tue, 10 Dec 2002 15:44:53 +0100
Message-ID: <3DF5FDE5.EB89D6CD@informatik.uni-freiburg.de> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: guntha@informatik.uni-freiburg.de
Subject: Re: problem compiling c-functions
In-Reply-To: <3DF5FDE5.EB89D6CD@informatik.uni-freiburg.de>
References: <3DF5FDE5.EB89D6CD@informatik.uni-freiburg.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox