Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: babi on October 09, 2012, 10:11:14 am

Title: problem while storing in an array
Post by: babi 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
Title: Re: problem while storing in an array
Post by: jarod42 on October 09, 2012, 10:36:13 am
Unrelated to CB.

(Note:
Code
numbers != numbers[i]
).
Title: Re: problem while storing in an array
Post by: babi 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