print contents a file that had been transferred into array

how to see the contents of the array after i use infile>>ecg[i] which means the file already being loaded into arrays. below are part of the codes. I used linux and the screen is on Nios 2 terminal.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include<fstream>
#include <stdio.h>
#define Fs 200
#define DELTA 8000
#define ECGlength 120000
#define BlockMinute 4*60
using namespace std;
  int main()
{
	ifstream infile("x2.txt");
	FILE * pFile;
	double ecg[ECGlength];
	double PPS[(ECGlength-Fs*BlockMinute)*2/Fs+1];
	for(int i=0;i<ECGlength;i++)
		infile>>ecg[i];
	{
	(fscanf(pFile, "%f\n", &ecg[ECGlength]) == 2)
         printf(stdout,"ECG: %f\n", ecg[ECGlength]);
	}
return(0);
}

I just tried wrote it that way, nut the terminal show nothing.
1) Line 18: a) Useless (comparsion does not do anything), b) Dangerous (Buffer overflow here)
2) It is not good idea to mix C++ stream operations and C output functions. And C++ and C-style file manipulation.
3) You will need a loop, like with input to output content of array.
Thank u for the reply. I will exclude that line. it is my pleasure if u can show me how to do like u suggest as number 3.
1
2
3
for(int i = 0; i < ECGlength; ++i) {
	std::cout << "ECG[" << i << "] = " << ecg[i] << std::endl;
}
thank youuu :)
Topic archived. No new replies allowed.