|
-
October 16th, 2012, 04:11 PM
#1
Need help guys!
Hi all,
I have been trying to read a comma separated .txt file into an array and print it to console in C++. The txt file consists of two columns of double type data. For some reason the program runs, but gives blank output in the console. I want to know if I am doing something wrong. So far this is what I have:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int i=0;
double x[10];
double y[10];
string line;
ifstream is;
is.open("UNTITLED.txt");
while(!getline(is,line).eof())
{
is >> x[i];
is >> y[i];
i++;
}
is.close();
for(int i=0;i<10;i++){
cout << "x=" << x[i] << "y= " << y[i] << endl;
}
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|