b) how would you find out how many are supported on our machines?
#include <stdio.h>
#include <stdlib.h>
void foo(int x) { fprintf(stderr,"(%i) bye.\n",x); }
int main()
{
atexit(foo);
sleep(2);
return 0;
}
BTW: compiling it to see what message is produced is a good
thing, but you're going to have to explain why there's
a problem here, so simply regurgitating the error message is not
acceptable.
| p0.c | p1.c | p2.c |
#include <stdio.h>
#include <stdlib.h>
int main()
{
setvbuf(stdout,0,_IONBF,0);
while(1)
{
int i;
for(i = 0; i < 5; ++i)
{
sleep(1);
fprintf(stdout,"%c",'X');
}
fprintf(stdout,"\n");
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
int main()
{
char B[12];
setvbuf(stdout,B,_IOLBF,12);
while(1)
{
int i;
for(i = 0; i < 5; ++i)
{
sleep(1);
fprintf(stdout,"%c",'X');
}
fprintf(stdout,"\n");
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
int main()
{
char B[64];
setvbuf(stdout,B,_IOFBF,12);
while(1)
{
int i;
for(i = 0; i < 5; ++i)
{
sleep(1);
fprintf(stdout,"%c",'X');
}
fprintf(stdout,"\n");
}
return 0;
}
|
Explain explain what the output behvior is for each of the three programs, and explain thoroughly why they behave differently!