Hi everyone,
I' ve got a problem. Let's say, I've got a file full of data (numbers) and I want to read them into a dynamic array. After doing it, I want to see, for instance, the third element of the array and the whole amount of numbers in the screen. How could I do that?
Here's the code
What should I do?
Thank you.
I' ve got a problem. Let's say, I've got a file full of data (numbers) and I want to read them into a dynamic array. After doing it, I want to see, for instance, the third element of the array and the whole amount of numbers in the screen. How could I do that?
Here's the code
Code:
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
main ()
{
int n =0;
int size = 0;
float *array=new float[3000];
ifstream inf("input.txt",ios::in);
while (inf>>*array)
{
size++;
}
cout <<size<<endl; //here I see the total amount of the numbers, it's good
cout <<array[2]<< endl; //here I see -4.31602e+008 , but it's not
// the right number
delete [] array;
inf.close();
return 0;
}
Thank you.
Comment