online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <vector> #include <string> #include <sstream> #include<fstream> int main() { std::string line; int word; std::ifstream inFile("input.txt"); //create/use a std::vector instead of builit in array std::vector<std::vector<int>> vec; if(inFile) { while(getline(inFile, line, '\n')) { //create a temporary vector that will contain all the columns std::vector<int> tempVec; std::istringstream ss(line); //read word by word(or int by int) while(ss >> word) { //std::cout<<"word:"<<word<<std::endl; //add the word to the temporary vector tempVec.push_back(word); } //now all the words from the current line has been added to the temporary vector vec.emplace_back(tempVec); } } else { std::cout<<"file cannot be opened"<<std::endl; } inFile.close(); //lets check out the elements of the 2D vector so the we can confirm if it contains all the right elements(rows and columns) for(std::vector<int> &newvec: vec) { for(const int &elem: newvec) { std::cout<<elem<<" "; } std::cout<<std::endl; } return 0; }
0 1 9 0 4 8 1 5 5 2 0 6 3 2 2 1 3 1 2 1 3 4 3 7 5 3 4

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue