Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <pthread.h>
- #include <unistd.h>
- #include <stdlib.h>
- using namespace std;
- struct Data{
- string a;
- string b;
- };
- void* thread_func( void *param ){
- struct Data *input = (struct Data*)param;
- string data1 = input->a;
- string data2 = input->b;
- cout << "You said: " << data1 << " " << data2 << endl;
- return NULL;
- }
- int main( int argc, char *argv[] )
- {
- pthread_t child;
- string arg, arg2;
- struct Data *input;
- cout << "Input 1: " << endl;
- cin >> arg;
- cout << "Input 2: " << endl;
- cin >> arg2;
- input->a = arg;
- input->b = arg2;
- pthread_create( &child, NULL, thread_func, (void *)&input);
- pthread_join( child, NULL );
- cout << "Synced" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement