PDA

View Full Version : Please explain this code to me



NickyLuv
25th March 2015, 08:43
Hi,

I'm using Qt 5.3.0 and this code is a solution to one of our assignment questions that we had to do. Please see my comments in the following extraction of code. Not sure if I understand it correctly:

else{
uName += lName;
int chars = 4 - lName.size();
if(fName.size() >= (chars +1)){ //what is the purpose of the +1?
fName.resize(chars +1);
uName += fName;
}
else{
uName +=fName;
uName += QString(5-uName.size(), '0'); //I suppose the '0' is to add zeros at the end of the string?

stampede
25th March 2015, 09:35
one of our assignment questions that we had to do
ok, so what was the question ?

NickyLuv
25th March 2015, 09:43
Thanks, attached is the question11031