Question about conditional statements.
Hello everyone!
I am wondering if you can declare a variable inside a conditional statement, and then use that variable out side of the conditional statement. Thank you! |
What programming language?
In C++ you cannot do that. |
Thanks for the reply.
Shell script. |
For bash the answer is basically "yes", but if a block of commands is executed in a subshell, then changes to variables in that block are not communicated back to the parent shell. A parenthesized list explicitly forces execution to a subshell. Commands run in the background are also done in a separate process. A block of commands with its input or output directed through a pipeline also causes those commands to be executed in a subshell, and this is a frequent cause of problems in shell scripts.
Code:
N=0 Code:
N=0 Code:
N=0 |
Thank you for the response!!! Solved my problem!!!
|
All times are GMT -5. The time now is 05:33 PM. |