问题描述
我正在尝试在旧的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
关键字。