Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ load file as vector

#include <iostream>
#include <iterator>
#include <fstream>
#include <vector>
#include <algorithm> // for std::copy

int main()
{
  std::ifstream is("numbers.txt");
  std::istream_iterator<double> start(is), end;
  std::vector<double> numbers(start, end);
  std::cout << "Read " << numbers.size() << " numbers" << std::endl;

  // print the numbers to stdout
  std::cout << "numbers read in:
";
  std::copy(numbers.begin(), numbers.end(), 
            std::ostream_iterator<double>(std::cout, " "));
  std::cout << std::endl;

}
Comment

PREVIOUS NEXT
Code Example
Cpp :: inbuilt function to convert decimal to binary in c++ 
Cpp :: array max and minimum element c++ 
Cpp :: c++ iterate over vector of pointers 
Cpp :: c++ default parameters 
Cpp :: c++ vector size 
Cpp :: Quicksort taking random pivot 
Cpp :: create a 2d vector in c++ 
Cpp :: c++ get string between two characters 
Cpp :: check if whole string is uppercase 
Cpp :: pointer address to string 
Cpp :: find index of element in array c++ 
Cpp :: break in c++ 
Cpp :: map declaration c++ 
Cpp :: continue statement in c++ program 
Cpp :: deep copy c++ 
Cpp :: min in c++ 
Cpp :: abs in cpp 
Cpp :: how to get the time in c++ as string 
Cpp :: c++ vector of class objects 
Cpp :: c++ struct constructor 
Cpp :: how to use toString method in C++ 
Cpp :: print pattern and space in cpp 
Cpp :: c++ replace 
Cpp :: after login redirect to dashboard in nuxt 
Cpp :: c++ split string by space into array 
Cpp :: best time to buy and sell stock leetcode solution 
Cpp :: passing structure to function in c++ example 
Cpp :: Traversing a C++ Array 
Cpp :: exponent power of x using c c++ 
Cpp :: how to take full sentence in c++ 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =