gpt4 book ai didi

c - 编译C程序时“Function prototypes are an ANSI feature”错误

转载 作者:行者123 更新时间:2023-12-02 10:44:49 26 4
gpt4 key购买 nike

我正在尝试在旧的HP 3000 MPE/iX计算机系统上调试编译器错误。错误是:

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.
代码如下。真诚的感谢您的帮助:
#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');
}

最佳答案

对于ANSI C之前的版本,您需要在函数头之后,主体的{之前声明函数的参数。您只需将参数名称放在括号中。因此,您将拥有:

int find_length(string)
char *string;
{
...
对于 main,只需删除 void关键字。

关于c - 编译C程序时“Function prototypes are an ANSI feature”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64434575/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com