Hi all,
I just spent 3 hours writing and debugging 37 lines of code. Is this normal or am I "below average" in coding abilities. I come from a C background and decided to write C++ code that I finally got right as shown below for the specific example:
Code:
#include <iostream>
#include <fstream>
#include <string>
#define SPACE_SEARCH 10
using namespace std;
void convertfile ()
{
string line;
ifstream oldfile;
ofstream newfile;
oldfile.open ("C:\\Before.txt");
newfile.open("C:\\After.txt");
for (int i = 0; !oldfile.eof(); i++){
getline(oldfile, line);
for (int j = 0; j <= SPACE_SEARCH; j++){
if(line[j] == ' '){
line.erase(0,j+1);
break;
}
}
newfile << line <<"\n";
}
oldfile.close();
newfile.close();
}
int main()
{
convertfile();
return 0;
}
As you may see, nothing spectacularly fancy, just a program that takes a text file source code including line numbers, example:
Code:
001 #ifndef FINDDIALOG_H
002 #define FINDDIALOG_H
003 #include <QDialog>
004 class QCheckBox;
005 class QLabel;
006 class QLineEdit;
007 class QPushButton;
and output into a text file, in the same directory, a source file without code lines:
Code:
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include <QDialog>
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;
I think it was more the learning along the way that consumed atleast 75% of my time for this specific case. But then again, I read that programming always entails learning along the way and so its somehow no excuse for the long time taken in this specific case.
So as a matter of interest, what pace do all of you operate on, on average? i.e. LOC/day, Debugs per day or any other indicator of productivity? And is the above case a very poor show of productivity?