World_guanhai 2020-07-24 17:51 采纳率: 0%
浏览 48

不知道是我写的有问题,还是C的ctype.h库有问题。

`/* mod_str.c -- 修改字符串*/
#include
#include
#include
void ToUpper(char *);
int PunctCount(const char *);
#define LIMIT 81
int main(void)
{
char line[LIMIT];
char * find;
puts("Please enter a line:");
fgets(line, LIMIT, stdin);
find = strchr(line, '\n');
if (find)
*find = '\0';
ToUpper(line);
puts(line);
printf("That line has %d punctunation characters.\n",\
PunctCount(line));
return 0;
}

void ToUpper(char * str)
{
while (*str)
{
*str = toupper(*str);
str++;
}
}

int PunctCount(const char * str)
{
int ct = 0;
while (*str)
{
if(ispunct(*str))
ct++;
str++;
}
return ct;
}


![图片说明](https://img-ask.csdn.net/upload/202007/24/1595583818_307273.png)![图片说明](https://img-ask.csdn.net/upload/202007/24/1595583884_80581.png)

求解决。。。。
  • 写回答

1条回答 默认 最新

  • 旭日初扬 2020-07-25 15:15
    关注

    图片说明
    可以运行啊
    是不是没有包含头文件
    #include "stdio.h"
    #include "string.h"
    #include "ctype.h"

    能不能换一个编译器,应该是编译器的问题

    评论

报告相同问题?

悬赏问题

  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵
  • ¥15 cfx离心泵非稳态计算