hey...can anyone show me what am doin wrong here?? cant get this program to loop till the user enters a character other than "y"....it prompts the first time and its a succes. prompts the second time but does not wait for response....
#include <stdio.h>
#include <string.h>
#define LEN 20
main()
{
int PorC, pid, status;
char path[LEN+1];
char argu[LEN+1];
char resp;
do
{
if ((PorC=fork())==0)
{
printf ("Enter the path name: ");
scanf ("%s",path);
printf ("Enter the argument: ");
scanf ("%s",argu);
/*opens the program provided as the path..the path is in the same directory as the main prog so the name of the prog is used*/
execl (path, path, argu, 0);
fprintf(stderr, "exec() call failed\n");
exit(-1);
}
else
{
printf("this is parent");
pid = wait(&status);
//exit(-1);
}
printf("\nDo you wish to continue? (Y/N): ");
scanf("%c", &resp);
}while (resp == 'y');
}