Click here to Skip to main content
15,920,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Resource error Pin
rushiraj.jhala22-Mar-07 19:47
rushiraj.jhala22-Mar-07 19:47 
AnswerRe: Resource error Pin
Phil J Pearson23-Mar-07 7:53
Phil J Pearson23-Mar-07 7:53 
GeneralRe: Resource error Pin
rushiraj.jhala23-Mar-07 19:24
rushiraj.jhala23-Mar-07 19:24 
Questionshellexecuteex Pin
deeps_cute22-Mar-07 19:07
deeps_cute22-Mar-07 19:07 
AnswerRe: shellexecuteex Pin
prasad_som22-Mar-07 19:27
prasad_som22-Mar-07 19:27 
AnswerRe: shellexecuteex Pin
Naveen22-Mar-07 20:03
Naveen22-Mar-07 20:03 
AnswerRe: shellexecuteex Pin
Stephen Hewitt23-Mar-07 12:29
Stephen Hewitt23-Mar-07 12:29 
QuestionLine Of Code counter - doesn't work Pin
XTAL25622-Mar-07 18:48
XTAL25622-Mar-07 18:48 
Hi, i have been working on an assignment for uni for the past week. Every week we get a new assignment, we create a small program and write a report showing a time log, defect report, etc. This one is a program to count Lines Of Code, in particular, class/object LOC.
I couldn't get it working so i submitted the buggy one, but i still need it complete to do the other assignments. Can someone take a look at it and tell me what's wrong, in particular this bit:
/* Basic trim function, removes start & end whitespace of a line */
void trim(string& str) {
    string::size_type pos = 0, n1 = 0, n2 = 0;
    while (n1 < str.length() || n2 < str.length()) {
        if ((n2 = str.find('\n', n1)) == string::npos)
            break;
        pos = str.find_last_not_of(" \t", n2);
        if(pos != string::npos && pos > n1) {
            str.erase(pos+1, n2-(pos+1));
            n2 = pos + 1;    // Move n2 back to start of deleted bit
            pos = str.find_first_not_of(" \t", n1);
            if(pos != string::npos) {
                str.erase(n1, pos-n1);
                n2 -= pos;   // Move n2 back again
            }
        }
        else
            str.erase(n1, n2-n1);
        n1 = n2 + 1;
    }
}

which should trim whitespace from the beginning & end of each line + remove any blank lines.

I have noticed that the string removal code is also buggy, i don't know what's wrong but it doesn't quite remove everything between " and "

Download File[^]. Includes input file
AnswerRe: Line Of Code counter - doesn't work Pin
toxcct22-Mar-07 20:50
toxcct22-Mar-07 20:50 
GeneralRe: Line Of Code counter - doesn't work Pin
XTAL25622-Mar-07 21:19
XTAL25622-Mar-07 21:19 
AnswerRe: Line Of Code counter - doesn't work [modified] Pin
John R. Shaw22-Mar-07 21:18
John R. Shaw22-Mar-07 21:18 
AnswerRe: Line Of Code counter - doesn't work Pin
kakan22-Mar-07 22:08
professionalkakan22-Mar-07 22:08 
GeneralRe: Line Of Code counter - doesn't work Pin
XTAL25623-Mar-07 14:15
XTAL25623-Mar-07 14:15 
QuestionHow to get the original size of a pe file Pin
white jungle22-Mar-07 18:38
white jungle22-Mar-07 18:38 
AnswerRe: How to get the original size of a pe file Pin
Karismatic22-Mar-07 23:10
Karismatic22-Mar-07 23:10 
GeneralRe: How to get the original size of a pe file Pin
white jungle22-Mar-07 23:18
white jungle22-Mar-07 23:18 
GeneralRe: How to get the original size of a pe file Pin
Karismatic23-Mar-07 0:22
Karismatic23-Mar-07 0:22 
GeneralRe: How to get the original size of a pe file Pin
white jungle23-Mar-07 0:33
white jungle23-Mar-07 0:33 
QuestionProblem Putting Dialog on top Pin
ghunzel0622-Mar-07 16:15
ghunzel0622-Mar-07 16:15 
AnswerRe: Problem Putting Dialog on top Pin
prasad_som22-Mar-07 18:28
prasad_som22-Mar-07 18:28 
GeneralRe: Problem Putting Dialog on top Pin
ghunzel0622-Mar-07 19:27
ghunzel0622-Mar-07 19:27 
GeneralRe: Problem Putting Dialog on top Pin
DLChambers23-Mar-07 16:04
DLChambers23-Mar-07 16:04 
QuestionFinding Duplicate attribute values in a XML doc Pin
sujanaz22-Mar-07 15:35
sujanaz22-Mar-07 15:35 
QuestionAny thing wrong in this peace of code? Pin
G Haranadh22-Mar-07 14:17
G Haranadh22-Mar-07 14:17 
AnswerRe: Any thing wrong in this peace of code? Pin
PJ Arends22-Mar-07 16:03
professionalPJ Arends22-Mar-07 16:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.