News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

problem while storing in an array

Started by babi, October 09, 2012, 10:11:14 AM

Previous topic - Next topic

babi

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

jarod42

#1
Unrelated to CB.

(Note: numbers != numbers[i]).

babi

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