gpt4 book ai didi

c - 尝试将 islower 与数组和指针一起使用...出现错误?

转载 作者:太空宇宙 更新时间:2023-11-04 07:29:25 25 4
gpt4 key购买 nike

我在下面的程序中尝试了数组,指针和字符串,但我不知道我哪里出错了。

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

// finding out the uper case and lower case in a string

int main()
{
char *arr_1[] = {"CalCulaTor", "DoveTail", "MachiNing"};
int i = 0, j;

while(*(arr_1 + i) != '\0')
{
printf(" %d letter is %s ",i,islower(*(arr_1 + i)) ? "Lower case " : "Not lower case");
printf("\n");
i++;
}

system("PAUSE");

return 0;
}

最佳答案

您的代码看起来可以处理单个字符串,但您有一个包含三个字符串的数组。您需要添加另一个循环来处理对该数组的迭代。

关于c - 尝试将 islower 与数组和指针一起使用...出现错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15286641/

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