缺少原型错误

时间:2011-11-17 02:00:27

标签: c

我收到一个我不理解但无法找到解决方案的错误。

错误如下:

缺少isANumber的原型

它引用的代码是:

double prompt(char *promptString) {

    printf("%s", promptString);
    char *input = "";
    scanf("%s", &*input);
    printf("%s\n", &*input);

    int check = isANumber(input);


if (check) {
    return (double) *input;
} else {
    return 0.00;
}

}

int isANumber(char *check) {

    int result = 0;    /* Current isdigit() return value */
    do                           /* Check that each character of the...*/
        result = isdigit(*check++);  /* ...string is a digit and move on...*/
    while (result && *check);       /* ...until non-digit found or at EOS */
    return result;  /* Return result of last isdigit() call */

}
库包括:

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

任何帮助将不胜感激:)

3 个答案:

答案 0 :(得分:1)

你无法转发那样的参考。您需要在引用之前声明或定义isANumber

将它放在prompt功能之前:

int isANumber(char *check);

答案 1 :(得分:1)

在使用之前声明原型

int isANumber(char *check);

或(更简单)交换功能

答案 2 :(得分:0)

你错过了

的原型
int isANumber(char *check) {

应该是:

int isANumber(char *);

在顶部。