[英]"Function prototypes are an ANSI feature" error while compiling C program
I am attempting to debug a compiler error on an old HP 3000 MPE/iX Computer System.我正在尝试在旧的 HP 3000 MPE/iX 计算机系统上调试编译器错误。 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');
}
For pre-ANSI C, you need to declare the arguments to a function after the function header, before the opening {
of the body.对于 ANSI C 之前的版本,您需要在函数头之后、函数体的开头
{
之前声明函数的参数。 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.对于
main
,只需去掉void
关键字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.