#include "pch.h"
#include <iostream>
#include <string.h>
#define SIZE 6
int main()
{
std::cout << "Hello World!\n";
const char *mingdan[SIZE] = { "什邡胡远琪","都江堰刘建","东莞樊东阳","绵竹孟超","邻水郭亚","武胜谢伊泽" };
int count = 0;
int i=0;
for (size_t i = 0; i < SIZE; i++)
if (strncmp(mingdan[i],"武胜",2)==0)
{
printf("发现:%s\n",mingdan[i]);
count++;
}
printf("这份名单中有%d个帅哥",count);
return 0;
}
```F5运行后

strncmp函数的应用,比较字符串的指定部分
最新推荐文章于 2024-06-28 12:27:30 发布