im trying to implement a help function that can be called if i type"/help" in the console. this function can be called anytime while the main function is running.
at first i thought of creating another thread to call that function but im not sure how to use threading in c++ without using a thread class like boost or something but im trying to not to use outside libs
There's no reason not to use outside libs imo. Boost::thread can be statically linked.
Regardless, threading is provided through various things, the main one being your OS. For Windows, this would be Win32 Threads. For Linux, this would probably be pthreads (although I believe there's one other used internally for low-level purposes). Not sure about Mac.
C++ also provides a built-in threading class as of C++11 via std::thread which some compilers (VC++ 2012, GCC, Clang) already support.
Well, think about how it would be provided as input. Are they providing it through the console? If so, aren't you waiting for input to do anything anyways? If not, throw the waiting off into a separate thread and do the dirty in the main thread.
well, i want the main thread call a bunch of processes meanwhile this function continously listens for "/help" from the console im not sure how to create that function.
apparently this is as far as i got before noticing in order to process the function normally i have to still input for the help function first then input for the question that was asked.
im trying to enter input once in the console and it will either answer the question being asked or use help function if "/help" is typed
lets say i have the main function calling a function that is asking this "pick a number" then i wait for the input to enter which is an int.
at the same time i want another function also listening to everything i input to check for this string "/help" if the input does not equal "/help" if ignore the function and continues on what it was doing
alright throwing the threading idea out of the picture,
let me try to draw a picture to describe what i am talking about
ask user question expecting string input->
enter input in console ->
checks the string for certain word ->
if string passes ignore previous function ->
enter into function that originally asked the question
lets say the function that is asking the question only wants a single string to be taken in
im trying to avoid placing a conditional statement around all the input locations in my entire program just to look for one word