Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Console Application

Console Application

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++data-structuresdebuggingperformance
31 Posts 7 Posters 69 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P parichaybp

    77F8910E cmp dword ptr [edx+14h],0 after F5 arrow stopes here .... i have just started learning VC++ so i have very less idea abt Debuggers..

    C Offline
    C Offline
    Cedric Moonen
    wrote on last edited by
    #18

    Ok, so it is not directly in your code probably. Now, put a breakpoint at the very begining of your program (by going on the line and pressing F9). Then ,put several breakpoints in relevant points in your program. Each time you press F5, the programm will advance to the next bbreakpoint. And there, you can watch to your variables and things like that. Try to play with it and understand how it works, it is really usefull and it will really help you a lot !

    P M 2 Replies Last reply
    0
    • C Cedric Moonen

      Ok, so it is not directly in your code probably. Now, put a breakpoint at the very begining of your program (by going on the line and pressing F9). Then ,put several breakpoints in relevant points in your program. Each time you press F5, the programm will advance to the next bbreakpoint. And there, you can watch to your variables and things like that. Try to play with it and understand how it works, it is really usefull and it will really help you a lot !

      P Offline
      P Offline
      parichaybp
      wrote on last edited by
      #19

      Thanks for the inforamtion. it will help me a lot.... i will try to do that..

      1 Reply Last reply
      0
      • P parichaybp

        program does not produce any output i dnt knwo where it is getting generated.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #20

        But you mentioned a compiler error. What is it? It will be a 4-digit number preceded by a C.


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        P 1 Reply Last reply
        0
        • C Cedric Moonen

          Ok, so it is not directly in your code probably. Now, put a breakpoint at the very begining of your program (by going on the line and pressing F9). Then ,put several breakpoints in relevant points in your program. Each time you press F5, the programm will advance to the next bbreakpoint. And there, you can watch to your variables and things like that. Try to play with it and understand how it works, it is really usefull and it will really help you a lot !

          M Offline
          M Offline
          Maxwell Chen
          wrote on last edited by
          #21

          It crashes at here: } while (_findnext (File_handle, &file_s) == 0);


          Maxwell Chen

          1 Reply Last reply
          0
          • D David Crow

            But you mentioned a compiler error. What is it? It will be a 4-digit number preceded by a C.


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            P Offline
            P Offline
            parichaybp
            wrote on last edited by
            #22

            This instruction at "0X77f8910e" referenced memory at "0xc7c7cf0".The memory could not be "read".

            D 1 Reply Last reply
            0
            • P parichaybp

              This instruction at "0X77f8910e" referenced memory at "0xc7c7cf0".The memory could not be "read".

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #23

              That's a run-time error, not a compilation error. There's a big difference between the two.


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              1 Reply Last reply
              0
              • P parichaybp

                Hi , Thanks for the reply. Can u plz check my code and tell me where the error is and why it is getting generated..?// /// Program to Generate Binary Tree of multiple files and multiple words. #include #include #include #include #include #include #include #include #define MAXWORD 100 struct tnode *addtree(struct tnode *,char *); void treeprint(struct tnode *); #define length (80) struct tnode { char *word; struct tnode *left; struct tnode *right; }; struct tnode *root1 = NULL; struct tnode *talloc(void) { return (struct tnode *) malloc(sizeof(struct tnode)); } char *strdup(char *s) { char *p; p=(char *) malloc(strlen(s)+1); if(p!=NULL) strcpy(p,s); return p; } //addtree add a node with w at or below p struct tnode *addtree(struct tnode *p,char *w) { int cond; if(p==NULL) { p=talloc(); p->word=strdup(w); p->left=p->right=NULL; } else if((cond=strcmp(w,p->word)) == 0) ; else if(cond < 0) p->left=addtree(p->left,w); else p->right=addtree(p->right,w); return p; } // treeprint : in order void treeprint(struct tnode *p) { if(p!=NULL) { treeprint(p->left); printf("%s\n",p->word); treeprint(p->right); } } void ListWords (char *); #define MAX_LEN 100 int main () { char dir[] = "D://Parichay/"; ListWords(dir); printf("\n\n\t\t Binary Tree :- Each Node Contains 1 word.\n\n"); treeprint(root1); return 0; } /////////Function to list words////// void ListWords (char *dir) { struct _finddata_t file_s; long File_handle; char name[MAX_LEN], words[length]; int j,size; _chdir(dir); if( (File_handle = _findfirst( "*", &file_s )) == -1L ) { printf( "No files in current directory!\n" ); } else if (file_s.attrib & _A_NORMAL) { sprintf (name, "%s",dir); //root = addtree (root, name); //////////////// FILE *fp; fp = fopen(name, "r"); if(fp == NULL) { printf("\n\n Message from _A_NORMAL."); printf("\n\nERROR: could not open file"); exit(EXIT_FAILURE); } else while (fscanf(fp, "%s", &words)!= -1) //while not the end of the file { size = strlen(words); /*determines length of each string */ for(j = 0; j

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #24

                parichaybp wrote:

                while (fscanf(fp, "%s", &words)!= -1) //while not the end of the file

                fscanf() can also return 0, which indicates a potential problem, but the while loop would continue. Is this intentional?


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                1 Reply Last reply
                0
                • P parichaybp

                  Hi , Thanks for the reply. Can u plz check my code and tell me where the error is and why it is getting generated..?// /// Program to Generate Binary Tree of multiple files and multiple words. #include #include #include #include #include #include #include #include #define MAXWORD 100 struct tnode *addtree(struct tnode *,char *); void treeprint(struct tnode *); #define length (80) struct tnode { char *word; struct tnode *left; struct tnode *right; }; struct tnode *root1 = NULL; struct tnode *talloc(void) { return (struct tnode *) malloc(sizeof(struct tnode)); } char *strdup(char *s) { char *p; p=(char *) malloc(strlen(s)+1); if(p!=NULL) strcpy(p,s); return p; } //addtree add a node with w at or below p struct tnode *addtree(struct tnode *p,char *w) { int cond; if(p==NULL) { p=talloc(); p->word=strdup(w); p->left=p->right=NULL; } else if((cond=strcmp(w,p->word)) == 0) ; else if(cond < 0) p->left=addtree(p->left,w); else p->right=addtree(p->right,w); return p; } // treeprint : in order void treeprint(struct tnode *p) { if(p!=NULL) { treeprint(p->left); printf("%s\n",p->word); treeprint(p->right); } } void ListWords (char *); #define MAX_LEN 100 int main () { char dir[] = "D://Parichay/"; ListWords(dir); printf("\n\n\t\t Binary Tree :- Each Node Contains 1 word.\n\n"); treeprint(root1); return 0; } /////////Function to list words////// void ListWords (char *dir) { struct _finddata_t file_s; long File_handle; char name[MAX_LEN], words[length]; int j,size; _chdir(dir); if( (File_handle = _findfirst( "*", &file_s )) == -1L ) { printf( "No files in current directory!\n" ); } else if (file_s.attrib & _A_NORMAL) { sprintf (name, "%s",dir); //root = addtree (root, name); //////////////// FILE *fp; fp = fopen(name, "r"); if(fp == NULL) { printf("\n\n Message from _A_NORMAL."); printf("\n\nERROR: could not open file"); exit(EXIT_FAILURE); } else while (fscanf(fp, "%s", &words)!= -1) //while not the end of the file { size = strlen(words); /*determines length of each string */ for(j = 0; j

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #25

                  parichaybp wrote:

                  root1 = addtree (root1, words);

                  Why do you keep reassigning a new value to root1? That variable should point to the root of the tree no matter what.

                  parichaybp wrote:

                  #define MAX_LEN 100

                  Paths can be longer than 100 characters. Use MAX_PATH instead.


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  1 Reply Last reply
                  0
                  • P parichaybp

                    Hi , Thanks for the reply. Can u plz check my code and tell me where the error is and why it is getting generated..?// /// Program to Generate Binary Tree of multiple files and multiple words. #include #include #include #include #include #include #include #include #define MAXWORD 100 struct tnode *addtree(struct tnode *,char *); void treeprint(struct tnode *); #define length (80) struct tnode { char *word; struct tnode *left; struct tnode *right; }; struct tnode *root1 = NULL; struct tnode *talloc(void) { return (struct tnode *) malloc(sizeof(struct tnode)); } char *strdup(char *s) { char *p; p=(char *) malloc(strlen(s)+1); if(p!=NULL) strcpy(p,s); return p; } //addtree add a node with w at or below p struct tnode *addtree(struct tnode *p,char *w) { int cond; if(p==NULL) { p=talloc(); p->word=strdup(w); p->left=p->right=NULL; } else if((cond=strcmp(w,p->word)) == 0) ; else if(cond < 0) p->left=addtree(p->left,w); else p->right=addtree(p->right,w); return p; } // treeprint : in order void treeprint(struct tnode *p) { if(p!=NULL) { treeprint(p->left); printf("%s\n",p->word); treeprint(p->right); } } void ListWords (char *); #define MAX_LEN 100 int main () { char dir[] = "D://Parichay/"; ListWords(dir); printf("\n\n\t\t Binary Tree :- Each Node Contains 1 word.\n\n"); treeprint(root1); return 0; } /////////Function to list words////// void ListWords (char *dir) { struct _finddata_t file_s; long File_handle; char name[MAX_LEN], words[length]; int j,size; _chdir(dir); if( (File_handle = _findfirst( "*", &file_s )) == -1L ) { printf( "No files in current directory!\n" ); } else if (file_s.attrib & _A_NORMAL) { sprintf (name, "%s",dir); //root = addtree (root, name); //////////////// FILE *fp; fp = fopen(name, "r"); if(fp == NULL) { printf("\n\n Message from _A_NORMAL."); printf("\n\nERROR: could not open file"); exit(EXIT_FAILURE); } else while (fscanf(fp, "%s", &words)!= -1) //while not the end of the file { size = strlen(words); /*determines length of each string */ for(j = 0; j

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #26

                    parichaybp wrote:

                    if (strcmp (file_s.name, ".") == 0 || strcmp (file_s.name, "..") == 0)

                    This can be shortened to just a single comparison:

                    if (file_s.name[0] == '.')

                    This does nothing for your problem, but it does help to remove unnecessary code.


                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                    "There is no death, only a change of worlds." - Native American Proverb

                    1 Reply Last reply
                    0
                    • P parichaybp

                      Hi , Thanks for the reply. Can u plz check my code and tell me where the error is and why it is getting generated..?// /// Program to Generate Binary Tree of multiple files and multiple words. #include #include #include #include #include #include #include #include #define MAXWORD 100 struct tnode *addtree(struct tnode *,char *); void treeprint(struct tnode *); #define length (80) struct tnode { char *word; struct tnode *left; struct tnode *right; }; struct tnode *root1 = NULL; struct tnode *talloc(void) { return (struct tnode *) malloc(sizeof(struct tnode)); } char *strdup(char *s) { char *p; p=(char *) malloc(strlen(s)+1); if(p!=NULL) strcpy(p,s); return p; } //addtree add a node with w at or below p struct tnode *addtree(struct tnode *p,char *w) { int cond; if(p==NULL) { p=talloc(); p->word=strdup(w); p->left=p->right=NULL; } else if((cond=strcmp(w,p->word)) == 0) ; else if(cond < 0) p->left=addtree(p->left,w); else p->right=addtree(p->right,w); return p; } // treeprint : in order void treeprint(struct tnode *p) { if(p!=NULL) { treeprint(p->left); printf("%s\n",p->word); treeprint(p->right); } } void ListWords (char *); #define MAX_LEN 100 int main () { char dir[] = "D://Parichay/"; ListWords(dir); printf("\n\n\t\t Binary Tree :- Each Node Contains 1 word.\n\n"); treeprint(root1); return 0; } /////////Function to list words////// void ListWords (char *dir) { struct _finddata_t file_s; long File_handle; char name[MAX_LEN], words[length]; int j,size; _chdir(dir); if( (File_handle = _findfirst( "*", &file_s )) == -1L ) { printf( "No files in current directory!\n" ); } else if (file_s.attrib & _A_NORMAL) { sprintf (name, "%s",dir); //root = addtree (root, name); //////////////// FILE *fp; fp = fopen(name, "r"); if(fp == NULL) { printf("\n\n Message from _A_NORMAL."); printf("\n\nERROR: could not open file"); exit(EXIT_FAILURE); } else while (fscanf(fp, "%s", &words)!= -1) //while not the end of the file { size = strlen(words); /*determines length of each string */ for(j = 0; j

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #27

                      Have you tried just navigating through the files/folders without adding anything to the tree data structure?


                      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                      "There is no death, only a change of worlds." - Native American Proverb

                      1 Reply Last reply
                      0
                      • P parichaybp

                        Hi, i written a console application from VC++, program is to generate a binary tree. program will take a directory as a input and generate a binary tree of words.. problem is if i give a small directory with 5 to 10 files program generates the binary tree properly if i select a big folder it gives below error can anyone help with this..??? ===================================================== This instruction at "0X77f8910e" referenced memory at "0xc7c7cf0".The memory could not be "read". Click OK to terminate the program Click on cancel to debug the program OK CANCEL ======================================================= Regards, Parichay.

                        M Offline
                        M Offline
                        Maxwell Chen
                        wrote on last edited by
                        #28

                        It crashes at here: } while (_findnext (File_handle, &file_s) == 0);


                        Maxwell Chen

                        P 1 Reply Last reply
                        0
                        • P parichaybp

                          Hi V2, i have sent again hope u get the solution. /// Program to Generate Binary Tree of multiple files and multiple words. #include #include #include #include #include #include #include #include #define MAXWORD 100 struct tnode *addtree(struct tnode *,char *); void treeprint(struct tnode *); #define length (80) struct tnode { char *word; struct tnode *left; struct tnode *right; }; struct tnode *root1 = NULL; struct tnode *talloc(void) { return (struct tnode *) malloc(sizeof(struct tnode)); } char *strdup(char *s) { char *p; p=(char *) malloc(strlen(s)+1); if(p!=NULL) strcpy(p,s); return p; } //addtree add a node with w at or below p struct tnode *addtree(struct tnode *p,char *w) { int cond; if(p==NULL) { p=talloc(); p->word=strdup(w); p->left=p->right=NULL; } else if((cond=strcmp(w,p->word)) == 0) ; else if(cond < 0) p->left=addtree(p->left,w); else p->right=addtree(p->right,w); return p; } // treeprint : in order void treeprint(struct tnode *p) { if(p!=NULL) { treeprint(p->left); printf("%s\n",p->word); treeprint(p->right); } } void ListWords (char *); #define MAX_LEN 100 int main () { char dir[] = "D://Paruichay//"; ListWords(dir); printf("\n\n\t\t Binary Tree :- Each Node Contains 1 word.\n\n"); treeprint(root1); return 0; } /////////Function to list words////// void ListWords (char *dir) { struct _finddata_t file_s; long File_handle; char name[MAX_LEN], words[length]; int j,size; _chdir(dir); if( (File_handle = _findfirst( "*", &file_s )) == -1L ) { printf( "No files in current directory!\n" ); } else if (file_s.attrib & _A_NORMAL) { sprintf (name, "%s",dir); //root = addtree (root, name); //////////////// FILE *fp; fp = fopen(name, "r"); if(fp == NULL) { printf("\n\n Message from _A_NORMAL."); printf("\n\nERROR: could not open file"); exit(EXIT_FAILURE); } else while (fscanf(fp, "%s", &words)!= -1) //while not the end of the file { size = strlen(words); /*determines length of each string */ for(j = 0; j

                          S Offline
                          S Offline
                          Stephen Hewitt
                          wrote on last edited by
                          #29

                          Why implement a binary tree yourself? Use std::set or std::multiset. Then you get a self balancing binary tree instead of you home spun version which isn't self balancing and thus can degenerate to linear rather then logarithmic performance. Your program is written at an unnecessarily low level - A common mistake with C++ programmers, especially those with a background in C (in my opinion). Steve

                          M 1 Reply Last reply
                          0
                          • S Stephen Hewitt

                            Why implement a binary tree yourself? Use std::set or std::multiset. Then you get a self balancing binary tree instead of you home spun version which isn't self balancing and thus can degenerate to linear rather then logarithmic performance. Your program is written at an unnecessarily low level - A common mistake with C++ programmers, especially those with a background in C (in my opinion). Steve

                            M Offline
                            M Offline
                            Maxwell Chen
                            wrote on last edited by
                            #30

                            Stephen Hewitt wrote:

                            Your program is written at an unnecessarily low level - A common mistake with C++ programmers, especially those with a background in C (in my opinion)

                            This is so true. It takes time for him to catch up this sense. But maybe he hadn't known the existing one, std::set, to use. Sometimes it might be of fun to code one's own toy (BTree in this case) to enjoy how it works.


                            Maxwell Chen

                            1 Reply Last reply
                            0
                            • M Maxwell Chen

                              It crashes at here: } while (_findnext (File_handle, &file_s) == 0);


                              Maxwell Chen

                              P Offline
                              P Offline
                              parichaybp
                              wrote on last edited by
                              #31

                              Hi, Can u plz tell me how to correct the error??

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups