I am very new to C++ (and very old in age); I just need to get a couple of simple explanations for a few things.
1. what does the following do? Why/how is is used?
for(int i = size - 1; i >= 0; i--)
and for(int i = 0; i < 8; i++)
I understand the concepts quite well; I just can't seem to go from pseudocode to actual code. After reading through the tutorial several times, I finally understand the loops.
2. I downloaded Codeblocks to use instead of Visual C++ 2010 Express because it seemed easier. However, I sometimes have to use stdio.h instead of #include<iostream> - WHY IS THIS??? This issue confuses me even more.
Thanks so much for the forum and vast information you all include.
The first loop is a decrement loop. It initializes i to size-1. Each time through the loop i is decremented until i goes negative. i.e. the second term is no longer true. Assuming size is 8, the loop will go from 7 to 0.
The second loop is the more common increment loop. i is initialized to zero. i is incremented each time through the loop until i is no longer less than 8. This means the loop executes exactly 8 times (0-7).
2) Are you using C style I/O such as printf? VS may include <cstdio> (C++ equivalent to <stdio.h> as part of <iostream>, while code blocks may not do so.
Wow, now I get it. Feeling extremely stupid now . . .Thank you for your simple explanation
I am not sure what you are asking regarding question 2. It was required to download VS C ++ 2010 express. Codeblocks was suggested on Youtube (videos I found that explained coding). Maybe I should uninstall one? Could they not be compatible in some way (even though I am not using both)?
code blocks is great but I decided not to use it because the gcc stdio.h has a well known imperfection in it - it doesn't exist! There are workarounds but why bother? So I went back to VSE 2013. Somebody might have the answer on a more suitable alternative so codeblocks doesn't have this proble?
I am not sure what you are asking regarding question 2.
Are you using C-style I/O (i.e. printf) or C++ I/O (i.e. cout)?
Which header files include other header file is implementation defined.
Therefore, two implementations may vary in which other headers <iostream> includes.
My supposition was that VS <iostream> includes <cstdio> (the C++ version of <stdio.h>). This being true, you can use printf freely without explicitly include <cstdio> or <stdio.h>. That said, it's poor style to assume that <cstdio> is automatically included, since there is no requirement that it is automatically included. If you're doing C-style I/O in a C++ program (not the best style), then you should explicitly include <cstdio>.