02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Tornado</strong> 2.0<br />

User’s Guide<br />

Table 5-9<br />

Shell C Interpreter Data-Type Assumptions<br />

Element<br />

variable<br />

variable used as floating-point<br />

return value of subroutine<br />

constant with no decimal point<br />

constant with decimal point<br />

Data Type<br />

int<br />

double<br />

int<br />

int/long<br />

double<br />

Table 5-10<br />

Data Types in the Shell C Interpreter<br />

Type Bytes Set Variable Display Variable<br />

int 4 x = 99 x<br />

(int) x<br />

long 4 x = 33<br />

x = (long)33<br />

x<br />

(long) x<br />

short 2 x = (short)20 (short) x<br />

char 1 x = 'A'<br />

x = (char)65<br />

x = (char)0x41<br />

double 8 x = 11.2<br />

x = (double)11.2<br />

(char) x<br />

(double) x<br />

float 4 x = (float)5.42 (float) x<br />

Strings, or character arrays, are not treated as separate types in the shell C<br />

interpreter. To declare a string, set a variable to a string value. 3 For example:<br />

-> ss = "shoe bee doo"<br />

The variable ss is a pointer to the string shoe bee doo. To display ss, enter:<br />

-> d ss<br />

The d( ) command displays memory where ss is pointing. 4 You can also use<br />

printf( ) to display strings.<br />

3. Memory allocated for string constants is never freed by the shell. See 5.3.8 Strings, p.183 for<br />

more information.<br />

4. d( ) is one of the WindSh commands, implemented in Tcl and executing on the host.<br />

176

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!