hey guys im new here. I recently started learning c++. I was reading through my book ( Mike McGrath C++ in easy steps third edition ) when i came to compiling a program i was making from the book. i had loads of errors. yet it was copied exactly from the book.
Here is the code:
Code:
#include <iostream>
using namespace std ;
// Arrays Program.
int main()
{
// Program code goes here.
// Declared then initiaised.
float nums[3] ;
nums[0] = 1.5 ; nums[1] = 2.75 ; nums[2] = 3.25 ;
// Declared and initialised.
char name[5] = { 'm', 'i', 'k', 'e', '\0' } ;
int coords[2] [3] = { { 1, 2, 3 } , { 4, 5, 5 } } ;
}
cout << "nums[0]: " << nums[0] << endl ;
cout << "nums[1]: " << nums[1] << endl ;
cout << "nums[2]: " << nums[2] << endl ;
cout << "name[0]: " << name[0]<< endl ;
cout << "string: " << name << endl ;
cout << "coords[0][2]: " << coords[0][2] << endl ;
cout << "coords[1][2]: " << coords[1][2] << endl ;
return 0 ;
}
Here are the errors from my compiler ( MiniGW )
Code:
arrays.cpp:20: error: expected constructor, destructor, or type conversion befor
e '<<' token
arrays.cpp:21: error: expected constructor, destructor, or type conversion befor
e '<<' token
arrays.cpp:22: error: expected constructor, destructor, or type conversion befor
e '<<' token
arrays.cpp:23: error: expected constructor, destructor, or type conversion befor
e '<<' token
arrays.cpp:24: error: expected constructor, destructor, or type conversion befor
e '<<' token
arrays.cpp:25: error: expected constructor, destructor, or type conversion befor
e '<<' token
arrays.cpp:26: error: expected constructor, destructor, or type conversion befor
e '<<' token
arrays.cpp:28: error: expected unqualified-id before "return"
arrays.cpp:30: error: expected declaration before '}' token
if anybody could please help me that would be appriciated. i dont know if its me or the book thats making the errors. Btw if anyone else has the book its page 19