"Function prototypes are an ANSI feature" error while compiling C program

286 Views Asked by At

I am attempting to debug a compiler error on an old HP 3000 MPE/iX Computer System. The error is:

cc: "func.c", line 8: error 1705: Function prototypes are an ANSI feature.
cc: "func.c", line 15: error 1705: Function prototypes are an ANSI feature.

The code is as follows. Help is sincerely appreciated:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#define MAX_LEN 80

int find_length( char *string )
{
   int i;
   for (i =0; string[i] != '\0'; i++);
   return i;
}

int main( void )
{
   char string[132];
   int result;
   int again = 1;
   char answer;
   printf( "This program finds the length of any word you ");
   printf( "enter.\n" );
   do
   {
      printf( "Enter the word: ");
      fflush(stdin);
      gets( string );
      result = find_length( string );
      printf( "This word contains %d characters. \n", result);
      printf("Again? ");
      scanf("%c", &answer);
   } while (answer == 'Y' || answer == 'y');
}
1

There are 1 best solutions below

0
On

For pre-ANSI C, you need to declare the arguments to a function after the function header, before the opening { of the body. You only put the names of the arguments in the parentheses. So you would have:

int find_length(string)
char *string;
{
    ...

For main, just get rid of the void keyword.