Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use val function in pascal
How to use val function in pascal
A string converted to the value val

Definition: process value; var V; Var code: integer);

Here:

S is a string type variable consisting of a series of numeric characters; .

V is an integer or a real variable;

The code is an integer variable.

Note: Val converts s into its digital form.

Example:

Var s: string; I, code: integer;

begin

s:= ' 1234 ';

val(s,I,code);

Writeln (1); { 1234 }

End.

And:

A numeric value converted to a string.

Definition: procedurestr (x [:width [:decimal]]; var S:string);

Note: Convert the value x to a string.

Example:

defined variable

s:string[ 1 1];

begin

Str(I,S);

IntToStr:= S;

End;

begin

writeln(IntToStr(-5322));

Readln

End.