I am new in C.
This is my code
#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;
}
Suppose I have an input 12:13:14PM
I want to find out if it is am or PM. But the above code only finds out if the whole char array is "PM" or not. I have seen other post by I could not understand them.