`/* 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)
求解决。。。。