04-05-2011
Quote:
Originally Posted by
Corona688
I think if it's a const int that should be permissible, since that would make xx guaranteed computable not just load-time but compile-time...
Unfortunately not - in c89 initialisers must be constant expressions. A constant expression is one that only uses
literal values and arithmetic operators, such as "2" or "3 * 2", not "3 * x", even if x is declared a const variable.
"const" does not mean "constant" - it merely means that the const variable itself cannot modify the memory at that address. Others can.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to assign a awk array for further processing later in the script. I can't seem to figure it out. If someone could look at this and help me, I would very much appreciate it.
Thanks in Advance.
for ( x = 1 ; x <= Var ; x++ ) {
if ( x in varr ) {
... (2 Replies)
Discussion started by: timj123
2 Replies
2. Shell Programming and Scripting
Running: GNU/Linux, 2.6.22.9-61.fc6 (hope that's the right info needed)
I am trying give the amount of RAM and the % used. I am using free command.
I am having some problems with this command
code:
1)T = `free | grep Mem | awk '{print $2}'`
F = `free | grep Mem | awk '{print $4}'`... (3 Replies)
Discussion started by: AngelFlesh
3 Replies
3. Shell Programming and Scripting
I have a string as "yes why not"
I want to create one array variable with contents as one word per place in array..
for above string,the array variable should contain...
x="yes,why,not"
x = yes
x = why
x = not
Please help me,I am stuck up in the problem since 2 days... (3 Replies)
Discussion started by: uday26
3 Replies
4. Shell Programming and Scripting
I want to ask the user to enter an X amount of file names. I want to put those names into an array and then loop back through them to verify they are in the directory. 1st- How would I assign the value to an array and what is the correct syntax. 2nd- how would i reference that array after I... (3 Replies)
Discussion started by: tvb2727
3 Replies
5. Shell Programming and Scripting
Hi Experts,
I'm having issue in assigning var with special character , please see below for complete details.
$ echo $SHELL
/bin/csh
$ cat bp
abd/asd/a
$ awk -F "/" '{print $NF}' bp | awk '{print $1}'
a
$ set a=`awk -F "/" '{print $NF}' bp | awk '{print $1}'`
$ echo $a ... (15 Replies)
Discussion started by: novice_man
15 Replies
6. Shell Programming and Scripting
Hi,
I have a piece of code as follows:
i=0
while read LINE
do
var = "$LINE"
i=$((i+1))
echo "${var}"
done < file
I want to assign value to the array var.
However, when i execute the script i get a error.
Please can you help me know what i am missing.
I ultimately want to... (2 Replies)
Discussion started by: sunrexstar
2 Replies
7. UNIX for Advanced & Expert Users
topic moved to programming (0 Replies)
Discussion started by: zing_foru
0 Replies
8. Shell Programming and Scripting
Hi all ,
I have a string like para1#para2#para3
i want to assign para1 as first element para2 as second and so on
i tried
IFS=#
set -A array para1#para2#para3
echo ${array}
para1 para2 para3
i want echo ${array}
para1 (2 Replies)
Discussion started by: max_hammer
2 Replies
9. Shell Programming and Scripting
Hello All,
Can you please help me with the below.
#!/bin/bash
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1"
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Discussion started by: Ariean
14 Replies
10. Shell Programming and Scripting
Hi,
I have a 10*10 two dimensional array. How do I assign value to all it's 100 elements at once? I don't want to open two for loops and assign one by one.
Thanks,
Amit (2 Replies)
Discussion started by: amit14august
2 Replies
ICALC(1) General Commands Manual ICALC(1)
NAME
icalc - interactive calculator
SYNOPSIS
icalc [ file ]
DESCRIPTION
Icalc is a algebraic calculator designed primarily for interactive use. Each formula definition file is read and compiled. The standard
input is then read, expressions are evaluated and results are sent to the standard output. If a newline is escaped using a backslash,
input is continued on the next line.
An expression contains real numbers, variable names, function calls, and the following operators:
+ - * / ^
Operators are evaluated left to right, except '^', which is right associative. Exponentiation has the highest precedence; multiplication
and division are evaluated before addition and subtraction. Expressions can be grouped with parentheses. Each result is assigned a num-
ber, which can be used in future expressions. For example, the expression ($3*10) is the result of the third calculation multiplied by
ten. A dollar sign by itself may be used for the previous result. All values are double precision real.
In addition, variables and functions can be defined by the user. A variable definition has the form:
var = expression ;
Any instance of the variable in an expression will be replaced with its definition. A function definition has the form:
func(a1, a2, ..) = expression ;
The expression can contain instances of the function arguments as well as other variables and functions. Function names can be passed as
arguments. Recursive functions can be defined using calls to the defined function or other functions calling the defined function.
To define a constant expression, simply replace the equals sign ('=') with a colon (':') in a definition. Constant expressions are evalu-
ated only once, the first time they are used. This avoids repeated evaluation of expressions whose values never change. Ideally, a con-
stant expression contains only numbers and references to previously defined constant expressions and functions. Constant function defini-
tions are are replaced by their value in any expression that uses them with constant arguments. All predefined functions and variables
have the constant attribute. Thus, "sin(PI/4)" in an expression would be immediately replaced by ".707108" unless sin() or PI were rede-
fined by the user. (Note that redefining constant expressions is not a recommended practice!)
A variable or function's definition can be displayed with the '?' command:
? name
If no name is given, all definitions are printed. The '>' command writes definitions to a file:
> file
Similarly, the '<' command loads definitions.
The following library of predefined functions and variables is provided:
PI the ratio of a circle's circumference to its diameter.
if(cond, then, else)
if cond is greater than zero, then is evaluated, otherwise else is evaluated. This function is necessary for recursive defini-
tions.
select(N, a1, a2, ..)
return aN (N is rounded to the nearest integer). This function provides array capabilities. If N is zero, the number of avail-
able arguments is returned.
rand(x) compute a random number between 0 and 1 based on x.
floor(x) return largest integer not greater than x.
ceil(x) return smallest integer not less than x.
sqrt(x) return square root of x.
exp(x) compute e to the power of x (e approx = 2.718281828).
log(x) compute the logarithm of x to the base e.
log10(x) compute the logarithm of x to the base 10.
sin(x), cos(x), tan(x)
trigonometric functions.
asin(x), acos(x), atan(x)
inverse trigonometric functions.
atan2(y, x)
inverse tangent of y/x (range -pi to pi).
AUTHOR
Greg Ward
SEE ALSO
ev(1), rcalc(1), tabfunc(1)
RADIANCE
2/3/95 ICALC(1)