Author Topic: problem while storing in an array  (Read 4533 times)

Offline babi

  • Single posting newcomer
  • *
  • Posts: 2
problem while storing in an array
« on: October 09, 2012, 10:11:14 am »
hi guys ,
i am new at learning  programming , i just downloaded  C:B and  started learning c++ over the last few days , one of the problems i am facing now is regarding this  following program regarding storing data in an array


#include <iostream>
using namespace std;

int main()
{
int numbers[10];
for (int i = 0; i < 10; i++)
{
cout << " Please enter number "<<i<<endl;
cin >> numbers;

}
return 0;
}


once i run the program i am able to input only upto 8 diff numbers in the array, it doesnt take the 9th number , after the 8th number has been inputted windows throws up an error that console windows host has stoped working , i am using win 7.

if i directly assign the values to the array like this


int b[] = { 1, 2, 3, 4, 5,6,7,8,9,10 };
for (int i = 0; i < 10; i++)
{
cout << "  number is "<<b<<endl;
}

then it works fine ,

the problem arises when iam using cin

i have visual studio 2010 installed as well and this prog is running alright on it


thanks a ton
« Last Edit: October 09, 2012, 10:37:35 am by babi »

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: problem while storing in an array
« Reply #1 on: October 09, 2012, 10:36:13 am »
Unrelated to CB.

(Note:
Code
numbers != numbers[i]
).
« Last Edit: October 09, 2012, 11:20:30 am by jarod42 »

Offline babi

  • Single posting newcomer
  • *
  • Posts: 2
Re: problem while storing in an array
« Reply #2 on: October 09, 2012, 11:05:26 am »
don't know if its not related to CB , since when i am running the exe file directly it working fine but when i am running it on CB then the windows error is showing up