How to read number from file(casting- the numbers has readen as string)- c++ qt
Unsolved
Qt Creator and other tools
-
Let's say I want to read this file:
///
readLine25
goToLine1
....
///
now,
How can I treat int as int? and the string as string?
I want to get the number,
for example in line 1 I want to get 25
an important note.
the string allways 8 chars- not less not more!
thanks:) -
@RuWex said in How to read number from file(casting- the numbers has readen as string)- c++ qt:
How can I treat int as int?
https://doc.qt.io/qt-6/qstring.html#toInt
To get the number string simply use https://doc.qt.io/qt-6/qstring.html#sliced
So, first call https://doc.qt.io/qt-6/qstring.html#sliced to get the part of the string which contains the int and then convert that string to int using https://doc.qt.io/qt-6/qstring.html#toInt
-