trying to fix input
This commit is contained in:
@@ -11,3 +11,9 @@ add_executable(${PROJECT_NAME} ${SOURCES} )
|
||||
target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
|
||||
|
||||
add_test(${PROJECT_NAME} "${CMAKE_SOURCE_DIR}/bin/testing.exe")
|
||||
|
||||
project(InputTartTest)
|
||||
set( CMAKE_CXX_STANDARD 11)
|
||||
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
add_executable(${PROJECT_NAME} input.cpp )
|
||||
target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
|
||||
|
||||
30
testing/input.cpp
Normal file
30
testing/input.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <tart.h>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <threads.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
int counter = 0;
|
||||
int main (int argc, char *argv[]) {
|
||||
char t = ' ';
|
||||
while(t != 'q') {
|
||||
std::cout << "input a char" << ftell(stdin) <<" [";
|
||||
fseek(stdin, 0, SEEK_END);
|
||||
if(ftell(stdin) > 0) {
|
||||
t = term_getche();
|
||||
rewind(stdin);
|
||||
std::cout << t;
|
||||
std::cout << "]\n\r ";
|
||||
return 0;
|
||||
}else {
|
||||
std::cout << "eof";
|
||||
std::cout << "]\r ";
|
||||
}
|
||||
|
||||
struct timespec b;
|
||||
b.tv_sec = 1;
|
||||
thrd_sleep(&b, NULL); // sleep 1 sec
|
||||
}
|
||||
std::cout << '\n';
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user