Home > Back-end >  Help multithreaded dynamic output time at the same time for input/output operation
Help multithreaded dynamic output time at the same time for input/output operation

Time:10-05

/* I am a vs2013 environment, when debugging shows that cannot resolve external symbol void _cdecl search (void *) and displayTime */

# include "stdafx. H"
#include
#include
#include
#include
#include
#include
#include

Void search (void *);
Void displayTime (void *);
HANDLE hStdOut;
CONSOLE_SCREEN_BUFFER_INFO csbi;


Int _tmain (int arg c, _TCHAR * argv [])
{
HStdOut=GetStdHandle (STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo (hStdOut, & amp; Csbi);
_beginthread (search, 0, NULL);
While (1) {
_beginthread (displayTime, 0, NULL);
Sleep (1000 l);
}
Return 0;
}

Void the search () {
Char a, [20].
While (1) {
Printf (" input query: ");
Scanf_s (" % s ", a);
Printf (" query results: % s \ n ", a);
Sleep (1000);
System (" CLS ");
}
}

Void displayTime () {
Char \ [30].
Char res [100].
 

COORD COORD.
DWORD result;
Coord. X=10;
Coord. Y=10;
While (1) {
 

Time_t SEC=time (NULL);
T struct tm;
Localtime_s (& amp; T, & amp; The SEC);
Printf (res, "% % 4 d years 02 on 02 d % d", t.t m_year + 1900, t.t m_mon + 1, t.t m_mday);
Printf (temp, "02 02 02 % d: % d: % d", t.t m_hour, t.t m_min, t.t m_sec);
Strcat_s (res, temp);

Sleep (1000 l);
WriteConsoleOutputCharacter (hStdOut, res, strlen (res), coord, & amp; The result);
The _endthread ();

}
}

CodePudding user response:

In advance statement function format for: void search (void *).
Implementation function format for: void the search () {...

Check yourself, of course, the linker can't find void search (void *).

According to you mean, should add the implementation section parameter, not only can,
  • Related