Thank you and I do realize that I wasn't as detailed in my question as I should have been.
Here is what I'm trying to do. I'm new to C++ and going through a book(C++ without fear) trying to get the basics. I'm on a chapter that is an introduction to the new C++0x features. I'm not able to get a range based for command example problem in the book to work.
This is the code which is straight out of the book:
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
#define SIZE_OF_ARRAY 5
int main() {
int arr[SIZE_OF_ARRAY];
int total = 0;
// For each element, prompt for a value,
// store, and add to total.
//
for (int& n : arr) {
cout << "Enter array value: ";
cin >> n;
total += n;
}
cout << "Here are the values: ";
// Print each element.
//
for (int n : arr)
cout << n << endl;
cout << "Total is: " << total << endl;
cout << "Now, I'm going to zero out ";
cout << "the values." << endl;
// Set each element to 0.
//
for (int& n : arr)
n = 0;
cout << "Here are the values: ";
for (int n : arr)
cout << n << endl;
system( PAUSE );
return 0;
}
Here are the build errors
||=== Example 10-2, Debug ===|
||In function 'int main()' : |
|17|error: expected initializer before ':' token|
|26|error: expected primary-expression before 'for'|
|26|error: expected ')' before 'for'|
|26|error: expected initializer before ':' token|
|29|error: expected ')' before ';' token|
|34|error: expected initializer before ':' token|
|38|error: expected primary-expression before 'for'|
|38|error: expected ')' before 'for'|
|38|error: expected initializer before ':' token|
|40|error: 'PAUSE' was not declared in this scope|
|41|error: expected primary-expression before 'return'|
|41|error: expected ')' before 'return'|
|11|warning: unused variable 'arr'|
||=== Build finished: 12 errors, 1 warnings ===|
I did go through the tutorial and was able to get tdm4-5-2 gcc installed and the sample programs to work. One thing I'm confused about is here
http://gcc.gnu.org/projects/cxx0x.html they state you need GCC 4.6.
I did try using tdm4-5-2 with command prompt and C::B again same errors.
Not sure what to do now, may skip this chapter, feel like I'm waisting too much time on this.