Look:
I find this statement printf("And now back to the console once again\n")Code:int main()
{
FILE *stream,*fp ;
if((stream = freopen("temp","w",stdout)) == NULL)
{
perror("fopen temp error");
return -1;
}
execl("/bin/ls","ls","-l",0);
freopen("/dev/tty","w",stdout);
printf("And now back to the console once again\n");
fclose(stream);
return 0;
}
sometimes it can run,sometimes it cann't run,why?How to correct?