I declared a character fileName outside an if statement and used it in an if statement inside another if statement. I would like to know how do I retrieve and print the value I scanned and stored in char filename from outside the if block.
my code snippet:
char fileName[30] = "";
if(pid2==0){
block of statements here
if(pid3==0){
block of statements here
}else if(pid3==-1){
block of statements here
}else{
printf ("\t CHILD2: Enter a filename: ");
scanf ("%s", fileName);
...
}
}else if(pid2==-1){
block of statements here
}else{
printf ("\t CHILD2: %s was successfully created!\n", fileName);