#pragma warning(disable:4996)
#include
#include
#include
using namespace std;
int strcompare(char *ch1, char *ch2)
{
for (int i = 0; i < 25; i++)
if (ch1[i] != ch2[i])
return 0;
return 1;
}
int main()
{
char *no = { "" };
while (1)
{
#ifndef F
for (int i = 0; i < 25; i++)
{
cin >> no[i];
}
#define F
#endif
time_t now = time(0);
char *dt = ctime(&now);
//cout << "本地日期和時間:" << dt <<endl;
//char *no = { "Tue Nov 22 18:29:30 2016\n" };
if (strcompare(dt, no) == 1)
{
for (int i = 0; i < 20; i++)
{
Sleep(1000);
cout << "\a";
}
}
}
system("pause");
return 0;
}
char *no = { "" };這樣不對,還是野指針,要改為這樣:char a;char *no;no = &a;這樣就不會有問題了