problem compiling c-functions - Mailing list pgsql-admin

From Aravind Babu Guntha
Subject problem compiling c-functions
Date
Msg-id 3DF5FDE5.EB89D6CD@informatik.uni-freiburg.de
Whole thread Raw
Responses Re: problem compiling c-functions
List 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


pgsql-admin by date:

Previous
From: "Mark and Kellie Gordon"
Date:
Subject: Connection Management
Next
From: CoL
Date:
Subject: Re: UNICODE -> SJIS problem