微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

编译C程序时出现“函数原型是ANSI功能”错误

如何解决编译C程序时出现“函数原型是ANSI功能”错误

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。