我想检查日期是否已经过去,但是我收到来自编译器的警告
warning: initialization of 'int' from 'char *' makes integer from pointer without a cast
warning: comparison between pointer and integer
并且您可能会看到即时消息只是从C开始
#include <stdio.h>
#include <time.h>
int main()
{
time_t rawtime;
struct tm* timeinfo;
char buffer[80];
time(&rawtime);
timeinfo = localtime(&rawtime);
printf("----------------------------------------\n");
strftime(buffer, 80, "%d%m%H%M", timeinfo); // Get date and time and format it as DDMMHM and store it in buffer
puts(buffer); // Print date stored in buffer
printf("----------------------------------------\n");
int as = "22051222"; // Set an int according to date of the first conditon
if ( as < buffer ) { // if as < than the date saved in buffer
printf("22/05/2020 - 12:22 ------ Florian.M\n\n"); // then print this line
} else {
printf("22/05/2020 - 12:22 ------ Florian.M>>>\n\n"); // else print this line
}
printf("----------------------------------------\n");
getchar();
return 0;
}
哪个是最好的方法
在此行:
if ( as < buffer )
int as = "22051222";