Solved Comparing contents of two Qfile(.txt)
-
I have two files I get the text from two files in two variables as line and line1. I want compare two variables by if statement
content of file:line=9 and line=31
if (line > line1) {
addto_logging ("line is greater than line1")
}
still line is less than line1, Qt output is line is greater than line1 that means it just comparing 9 and 3 not 9 and 31. what wrong here? -
@shree_121 Wrong is here the way you're comparing. Strings are compared lexically (character by character, it does not interpret content): https://doc.qt.io/Qt-5/qstring.html#operator-gt
-
@jsulm thank you, is there any way other way that i can convert content file in integer format sothat easy to compare big values.
-
@shree_121 Sure, but you will need to parse the strings by yourself to locate the numbers, then you can convert them using https://doc.qt.io/Qt-5/qstring.html#toInt
-
@jsulm Thank you so much this exactly what i want.