#include <stdlib.h>
//recommended headers for wait(), if CC says wait not defined, try these:
// #include <sys/types.h>
// #include <sys/stat.h>
#include<iostream>
usingnamespace std;
int main()
{
int array[4];
int id;
int *res;
int ret;
for (int count = 0; count < 4 ; count++)
{
array[count] = count*100;
}
id = fork();
if (id == 0)
{
cout << "kid" << endl;
return 99;
}
else
{
wait(res);
ret = ( *res);
cout << res;
cout << ret;
}
return 0;
}
That's a small program I wrote to get a feel for fork() and wait(), but I've ended up with a ridiculous compiler error:
forker.cpp:37: error: no match for ‘operator*’ in ‘*res’
forker.cpp:38: error: no match for ‘operator<<’ in ‘std::cout << res’
forker.cpp:13: warning: unused variable ‘res’
the first error seems to say that it doesn't know what the dereference operator does. I thought that I could be passing wait() an incorrect type, but my notes and the error messages don't seem to say that anything is wrong with that.
I also know that some of the code doesn't really amount to any result, but this is just a small incomplete program for trying out syntax.