我是C的新人
这是我的代码
#include <iostream>
#include <string.h>
using namespace std;
int main() {
char time[20];
scanf("%s",time);
// command and "hello" can be less than, equal or greater than!
// thus, strcmp return 3 possible values
if (strcmp(time, "PM") == 0)
{
printf("It's PM \n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
假设我在下午12:13:14输入
我想知道它是上午还是下午.但上面的代码只发现整个char数组是否为"PM".我看过其他帖子,我无法理解它们.