how i can translate int to string?
var
int1 = readLine() #at example 5
int2 = 5
echo int1+int2 #result 10
You may also consider to read some of the fine tutorials and books to learn Nim :-)
For Nim we have the $ letter for universal "to string" conversion, which works for most data types including int. So try
echo $(int1 + int2) # plain $int1 for single value
Other functions with more formating options, for example leading zeros for ints or decimal digits for float exists also, see std lib.
ok, why it doesn't works now?
var
int1 = readLine(stdin) #at example 5
int2 = 5
echo $(int1 + int2) #result 10
C:\Users\Администратор\Desktop\nim-0.19.0\bin>nim c --cc:vcc --cpu:i386 n.nim
Hint: used config file 'C:\Users\╨Р╨┤╨╝╨╕╨╜╨╕╤Б╤В╤А╨░╤В╨╛╤А\Desktop\nim-0.19.0\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: n [Processing]
n.nim(5, 13) Error: type mismatch: got <TaintedString, int>
but expected one of:
proc `+`(x: int8): int8
first type mismatch at position: 1
required type: int8
but expression 'int1' is of type: TaintedString
proc `+`(x, y: float32): float32
first type mismatch at position: 1
required type: float32
but expression 'int1' is of type: TaintedString
proc `+`(x, y: int16): int16
first type mismatch at position: 1
required type: int16
but expression 'int1' is of type: TaintedString
proc `+`[T](x, y: set[T]): set[T]
first type mismatch at position: 1
required type: set[T]
but expression 'int1' is of type: TaintedString
proc `+`(x, y: int8): int8
first type mismatch at position: 1
required type: int8
but expression 'int1' is of type: TaintedString
proc `+`(x: float): float
first type mismatch at position: 1
required type: float
but expression 'int1' is of type: TaintedString
proc `+`(x: int16): int16
first type mismatch at position: 1
required type: int16
but expression 'int1' is of type: TaintedString
proc `+`(x: int32): int32
first type mismatch at position: 1
required type: int32
but expression 'int1' is of type: TaintedString
proc `+`(x, y: int32): int32
first type mismatch at position: 1
required type: int32
but expression 'int1' is of type: TaintedString
proc `+`(x, y: int): int
first type mismatch at position: 1
required type: int
but expression 'int1' is of type: TaintedString
proc `+`(x, y: int64): int64
first type mismatch at position: 1
required type: int64
but expression 'int1' is of type: TaintedString
proc `+`(x: int64): int64
first type mismatch at position: 1
required type: int64
but expression 'int1' is of type: TaintedString
proc `+`(x: int): int
first type mismatch at position: 1
required type: int
but expression 'int1' is of type: TaintedString
proc `+`[T: SomeUnsignedInt](x, y: T): T
first type mismatch at position: 1
required type: T: SomeUnsignedInt
but expression 'int1' is of type: TaintedString
proc `+`(x: float32): float32
first type mismatch at position: 1
required type: float32
but expression 'int1' is of type: TaintedString
proc `+`(x, y: float): float
first type mismatch at position: 1
required type: float
but expression 'int1' is of type: TaintedString
expression: int1 + int2
oh, sorry, I was wrong with the name of the topic
Using explicit data types makes it easier to discover what is going on...
from strutils import parseint
var
s: string = readLine(stdin)
int1: int = parseint(s)
int2 = 5
echo int1 + int2