未定义引用`polyndrom',`uppercase'和`lowercase'

时间:2018-03-29 03:20:05

标签: c

为什么我在c:

中收到此错误
  

lab_6.c :(。text + 0x53):对polyndrom' ,大写'和'小写'的未定义引用

include stdio.h 
include stdlib.h 
include string.h 

int polyndrom (char str[]);
int uppercase (char ch);
int lowercase (char ch);
int isNumber (char str[]);
int isReal (char str[]);

int main (int argc, char *argv[])
{

    FILE *fp = fopen (argv[1], "r");
    char buf[50];

    //Check whether the file exists or not
    if (fp == NULL) {
        printf ("check file name is proper or not\n");

    }

    //Read string
    while (fscanf (fp, "%s", buf) != EOF) {
        //Check if the string is a polyndrom or not
        if (polyndrom (buf) == 1) {
            printf ("String %s is a palindrome\n", buf);
        }
        else {
            printf ("String %s is not a palindrome\n", buf);
        }
        printf ("Its first character is %c\n", buf[0]);
        printf ("Its length is %u\n", strlen (buf));

        int i = 0, countUpper = 0, countLower = 0;
        while (buf[i] != '\0') {
            //check if the character is uppercase or not
            if (uppercase (buf[i]) == 1) {
                countUpper++;
            }
            //check is the character is lowercase or not
            if (lowercase (buf[i]) == 1) {
                countLower++;
            }
            i++;
        }

        printf ("It has %d uppercase letters\n", countUpper);
        printf ("It has %d lowercase letters\n", countLower);
        printf ("\n");

        //check is the string is a real number or not
        if (isReal (buf)) {
            printf ("String %s is a real number. \n\n", buf);
        }
        else {
            printf ("String %s is a interger. \n\n", buf);
        }
    }
}

int polyndron (char str[])
{
    int start = 0;
    int end = strlen (str - 1);

    while (start < end) {
        if (str[start++] != str[end--]) {
            return 0;
        }
    }

    return 1;
}

int uppercas (char ch)
{
    if (ch >= 'A' && ch <= 'Z') {
        return 1;
    }

    return 0;
}

int isRumber (char str[])
{
    int i;

    for (i = 0; str[i] != '\0'; i++) {
        if (isdigit (str[i]) != '.') {
            return 0;
        }
    }

    return 1;
}

int isReal (char str[])
{
    if (strchr (str, '.') != NULL) {
        return 1;
    }

    return 0;
}

1 个答案:

答案 0 :(得分:0)

检查你的拼写。名称必须准确。