I am trying to get cin on a different thread so that the cin will run without interfering with the cout stuff, but, this is my first time even thinking really of figuring out threads as i am still new (hints the beginner section) and so much is wrong with this but idk what
#include <QCoreApplication>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <thread>
usingnamespace std;
string typesome;
thread releasecin;
int main()
{
thread relc(releasecin, getline(cin, typesome);
relc.join();
cout << "Hey type something while i talk\n";
cout << "I am a nice person\n";
cout << "I like pie\n";
cout << "At any time if i get out of line just type you good cuz to stop me\n";
getline(cin, typesome);
if (typesome == "you good cuz")
cout << "You typed " << typesome << " I will stop";
elsecontinue;
cout << "this is my story\n";
}
void releasecin()
{
std::thread relc(releasecin, getline(cin, typesome));
};
#include <QCoreApplication>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <thread>
#include <unistd.h>
#include <cstdlib>
usingnamespace std;
string typesome;
thread function1;
void function_1()
{
//cout << "I am Running.. - CIN";
getline(cin, typesome);
//std::thread relc(releasecin, getline(cin, typesome));
if (typesome == "you good cuz")
{
cout << "You typed " << typesome << " I will stop\n";
system("exit");
}
else
{
cout << "this is my story\n";
}
};
int main()
{
std::thread t1(function_1); // Start the CIN
// t1.join(); // Waits for the CIN to load
cout << "Hey type something while i talk\n";
usleep(10000000);
cout << "I am a nice person\n";
cout << "I like pie\n";
usleep(10000000);
cout << "At any time if i get out of line just type you good cuz to stop me\n";
if (typesome == "you good cuz")
cout << "You typed " << typesome << " I will stop";
else
cout << "this is my story\n";
usleep(10000000);
cout << "West philly born and raised\n";
return 0;
}
It tells me the i typed thing and all that but waits to get to the west philly born and raised part before it exits, any help is appreciated