online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <string> #include <vector> void stats(const std::vector<std::vector<std::string>>& vec) { std::vector<std::pair<std::string, int>> orderedCards; for (const auto& client : vec){ //scan database for cards and make ordered vector of pairs if (orderedCards.empty()){ //insert first pair to empty vector std::cout << "insert: make_pair(" << client[1] << ",1\n"; orderedCards.push_back(std::make_pair(client[1],1)); }else{ //for each new client scan vector and add new client/increment counter std::cout <<"start loop\n"; for (auto pair = orderedCards.begin(); pair != orderedCards.end(); ++pair){ std::cout << client[1][0] << " : " << pair->first[0] << "\n"; if (client[1][0] < pair->first[0]){ //compare first letter of new client and existing client orderedCards.insert(pair, std::make_pair(client[1], 1));// if its smaller, insert in front break;// break iteration and go for next client } else if (client[1] == pair->first){ //if theyre the same, increment counter pair->second+=1; break; } else if (pair+1 == orderedCards.end()){ //if end is reached, there was no existing client thus add new one with high letter orderedCards.push_back(std::make_pair(client[1], 1)); } std::cout <<"end loop\n"; } } } std::cout <<"second loop\n"; for (const auto& count : orderedCards) std::cout<<count.first<<" "<<count.second<<std::endl; //print on each line card and counter } std::vector<std::vector<std::string>> dataBase; int main() { dataBase={{"name", "bankcard"},{"name", "visa"},{"name", "bankcard"},{"name", "mastercard"},{"name", "bankcard"},{"name", "visa"}}; stats(dataBase); return 0; }

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