So the user enter the following doubles: 1.5 2.45 3.1 4.1 5.8 , how do i split these into 5 elements and store them into an array?
any help would be appreciated or links to helpful sites.
So the user enter the following doubles: 1.5 2.45 3.1 4.1 5.8 , how do i split these into 5 elements and store them into an array?
any help would be appreciated or links to helpful sites.
Last edited by Salem; 10-05-2012 at 11:38 PM. Reason: snip link to copy/paste question
yeah i used a for loop :
for ( int i = 0 ; i < 10; i++ ) {
scanf( "%d", &number );
b[ i ] = number;
but if i enter any numbers not in the order of 1 2 3 4 5 6 ... the loop just keeps going and does not stop.
> the loop just keeps going and does not stop.
Perhaps it's because %d is for decimal integers, not doubles.
Post your complete code, not 2 line snippets.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.