qt - QStringList "index out of range" -
i trying reverse words withing qstringlist. below code now, keep on getting "index out of range" error. error seem trying use data out of scope, not able figure out problem.
qstring reversed; qstringlist reversedlist; qstringlist list = input.split(" "); (int i=0;i<list.length(); ++1) reversedlist[i] = list[list.length() -1 -i]; reversed = reversedlist.join(" ");`
thanks
your reversedlist empty. have append items, this:
reversedlist.push_back (list[list.length () - 1 - i]);
naturally, trying access non-existing items via reversedlist[i]
not work , throws index-out-out-range error.
Comments
Post a Comment