Last active
June 5, 2016 17:42
-
-
Save nkoehring/7d6a78d37652b1c432f2d9ce514ccc07 to your computer and use it in GitHub Desktop.
read line delimited floating numbers from a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <stdlib.h> | |
using namespace std; | |
int main () | |
{ | |
double arr[5]; | |
string tmp; | |
int i = 0; | |
ifstream fp("numbers.txt"); | |
while (fp >> tmp) | |
arr[i++] = atof(tmp.c_str()); | |
while(--i>=0) | |
cout << "Number " << i << " is " << arr[i] << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Testfile