Skip to content

Instantly share code, notes, and snippets.

@tjukic
Last active March 6, 2017 14:04
Show Gist options
  • Save tjukic/13f689e796d155d103378786696d8723 to your computer and use it in GitHub Desktop.
Save tjukic/13f689e796d155d103378786696d8723 to your computer and use it in GitHub Desktop.
Prepend line nums - c++
#include "stdafx.h"
#include <fstream>
#include <string>
using namespace std;
int main() {
std::string srcline, nt;
auto li = 0;
std::ifstream tf("pocetni.txt");
while (std::getline(tf, srcline)) { nt += "[" + std::to_string(li++) + "] "+ srcline + "\n";
}
tf.close();
std::ofstream ntf("zavrsni.txt");
ntf << nt;
ntf.close();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment