- #1
BRN
- 108
- 10
Hello everybody,
I created this tamplet to upload a file matrix:
Unfortunately it does not provide me with the correct output. I get this:
I can't understand why I get those zeros. Any idea?
I created this tamplet to upload a file matrix:
Load Matrix:
#include <sstream>
#include "fstream"
#include <vector>
#include <iostream>
#include <string>
template<class T >std::istream& readMatrix(std::vector<std::vector<T>>& outputMatrix, std::istream& inStream)
{
if (inStream) {
std::string line;
while (std::getline(inStream, line)) {
outputMatrix.emplace_back();
// Break down the row into column values
std::stringstream split(line);
int value;
while (split >> value)
outputMatrix.back().push_back(value);
}
}
return inStream;
}
Unfortunately it does not provide me with the correct output. I get this:
Output:
input:
1234
5678
9123
4567
output:
1234 0 0 0
5678 0 0 0
9123 0 0 0
4567 0 0 0
I can't understand why I get those zeros. Any idea?