I have the following code:
Code:
cout<< "num_of_spcs_to_add is: " << num_of_spcs_to_add <<endl;
cin.get();
if ((num_of_spcs_to_add != 0) && (!num_of_spcs_to_add < 0)) { //this prevents trying to fix a column row which doesn't need any fixin'
cout<< "if statement entered." <<endl;
//fix current row of column:
for (size_t i = 0; i < num_of_spcs_to_add; i++) {
spcs_str += ' ';
}
current_subtype_str.insert(0, spcs_str); //add spaces in front of column row string so we can shift column row to the right
//fix current line:
buffer_str.replace(subtype_start_pos, current_subtype_str_size, current_subtype_str);
cout<< "buffer_str is: " << buffer_str <<endl;
cin.get();
current_subtype_str_size = current_subtype_str.size(); //since it just changed
complete_file_str->replace(original_line_pos, buffer_str_size, buffer_str); //replace the current line in the complete file's string
//with the new version, which has the necessary
//spaces added
buffer_str_size = buffer_str.size(); //since it just changed
}
and output shows that "num_of_spcs_to_add" is 3 at a particular time. Therefore the following if statement "if ((num_of_spcs_to_add != 0) && (!num_of_spcs_to_add < 0))" SHOULD be entered, since num_of_spcs_to_add is both not 0 and not less than 0. However, it doesn't, which is shown since neither output statement is executed.
Now can anyone please explain why the if statement is not being entered?
Thanks in advance.