May 3, 2013 at 10:39pm UTC
You must include header <string>. Also any array declared as having N elements provides indexes to its elements in the range 0, N - 1
Last edited on May 3, 2013 at 10:39pm UTC
May 3, 2013 at 10:59pm UTC
I already add the header
and change the n elements
but still not working it gives me this error
"warning: no newline at end of file"
May 3, 2013 at 11:29pm UTC
That's a warning not an error. Just add a newline after line 23.
May 6, 2013 at 6:36pm UTC
I did so
and now it works
But the Run Fails...
RUN FAILED(exit value 1, total time: 2s)
May 6, 2013 at 8:01pm UTC
Hi there,
read this:
http://www.tutorialspoint.com/cprogramming/ on arrays.
Change the size of your array to five. this should fix your problem.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <iostream>
using namespace std;
int DNumber;
string a[5];
int n;
int main() {
a[0] = "1) Cola" ;
a[1] = "2) Fanta" ;
a[2] = "3) Sprite" ;
a[3] = "4) Water" ;
a[4] = "5) Lemonade" ;
cout << "Please choose any of this flavors:" << endl;
cout << a[0] << endl;
cout << a[1] << endl;
cout << a[2] << endl;
cout << a[3] << endl;
cout << a[4] << endl;
cout << "Size of my array is : " <<sizeof (a) / sizeof (a[0]) << endl;
cin >> DNumber;
return 0;
}
Last edited on May 6, 2013 at 8:01pm UTC
May 6, 2013 at 9:50pm UTC
Duh
yeah... that happens
thanks a lot!
Lesson learn the hard way! n.n