Hi.
I'm new in C++ and sure - I'm learning it.
But - just interesting - how next bash function can't looks like in C++?
This code used to check array of system global variables:
Code:
#!/usr/bin/env bash
# defining and fill array
variables=( [1]=$sysvar1
[2]=$sysvar2
[3]=$sysvar3
[4]=$sysvar3
)
# function
checkvars () {
local var
# run loop for list of arguments one-by-one
for var in "$@"
do
# test - if $var not empty will print "Var exist"; else - "Empty var"
[[ "$var" ]] && echo "Var exist: $var;" \
|| echo "Empty var!"
done
}
# start function with array as argument
checkvars "${variables[@]}"
It's simple enough and I hope C++ code will not be too complicated for me to understand it :-)
Thanks.
P.S. Goal of post - not really made some job for me - but show an example of some C++ code, which I'll can sort out and compare with bash code.
Some explanations will be nice.