Ok guys im now at lesson 8 (Arrays)
So i took the quiz:
4. Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?
I answered the B,while the correct was A.
Frmoo what i know the only thing we can access "directly" is always the last element(in this case 100)
So why cant i get 7?
Is this a general case?I should remove 1(-1) to get the element i want everytime?
If i want to access the 10th element,should i put foo; ?
Also:Now reading part 9 (Strings)
So i saw this example:
Regarding "cin.getline ( string, 256, '\n' );"
using namespace std;
char string; // A nice long string
cout<<"Please enter a long string: ";
cin.getline ( string, 256, '\n' ); // Input goes into string
cout<<"Your long string was: "<< string <<endl;
i didnt find any actual reason to include the 256 after the string so i maddified it to:
cin.getline ( string,'\n' );
and it worked.
Whats the difference?