Like Tree19Likes

Somewhere in my program I'm not freeing memory. Can't find where

This is a discussion on Somewhere in my program I'm not freeing memory. Can't find where within the C++ Programming forums, part of the General Programming Boards category; I don't know why its returning those warning when before, with the same code in the playSound function, the one ...

  1. #31
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    I don't know why its returning those warning when before, with the same code in the playSound function, the one you quoted, I didn't have the addition in the array the code compiled but my program was broken, and after the addition was put in the array the program worked. So something is happening there.

  2. #32
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by jeremy duncan View Post
    I don't know why its returning those warning when before, with the same code in the playSound function, the one you quoted, I didn't have the addition in the array the code compiled but my program was broken, and after the addition was put in the array the program worked. So something is happening there.
    What's happening is that your code is horrible horrible horrible, and alot of people in this thread have tried to get through to you with this message, yet you seem to be gladly ignoring it.

    The description of the problem you are trying to solve, does not warrant this kind of copy-paste coding. It can be solved with plain, pretty, non-repetitive, non-spaghetti ordinary C++.
    Scrap this abomination, start anew, turn your compilers warning-levels up (-Wall with GCC/MingW), sit down with the problem, a piece of paper and a pencil, figure out a simple elegant solution to the problem, put it into code, fix ALL errors and warnings. Then come back here if it still doesn't work.
    Salem likes this.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  3. #33
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    Hi Neo1,

    I'm not going to pontificate over coding practices.

  4. #34
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by jeremy duncan View Post
    Hi Neo1,

    I'm not going to pontificate over coding practices.
    Poor coding practices lead to incorrectness. You're having issues with your code, and you haven't a hope in hell of finding the root of this issue, because your code is 10 or 100 times longer than it has to be, your naming scheme is atrocious, and furthermore, you can't get any help with it because nobody else can understand it either.

    If you want your program to work, follow good coding conventions. If not, then why are you here?
    Salem likes this.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  5. #35
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    I'm doing the best I can right now.

  6. #36
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by jeremy duncan View Post
    I'm doing the best I can right now.
    I don't believe you are. When looking at your code it is clear that you understand arrays, you understand loops and a host of other language features, yet you don't use these features.

    Seems like lazyness to me. If you want to rush development to get quick results, then that's fine, alot of people do that. C++ is horrible for this though, i would suggest a language like Java for this. It's quite similar to C++ syntactically, it shouldn't take you long to learn, and it has a huuuge standard library with functions and classes for everything, so you don't have to do it all by hand each time and you won't have to manage memory by hand. It lets you get your hands dirty right away. It will still punish you for coding like you have been doing so far, but generally it will require less work than C++.

    In any case (and especially if you decide to stick with C++), you have to stop being lazy like this. Don't ever name your variables using numbers, if you're doing this then that means you can do the same with an array and a loop, in a much cleaner and prettier fashion, which will also be easier to debug and it won't take up 1000 lines of code. Don't ever use #defines in C++, use "const" variables. Don't ever use a name like "gF" or "string1" for a variable, use descriptive names so you won't have to memorize what each variable is for, let the code document itself. Also, pick a naming scheme and stick with it.

    Don't try to rush when doing these programs, try to learn from them instead.
    Salem likes this.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  7. #37
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    "I'm not going to pontificate over coding practices."

    You're obviously a troll. Why else would you make a thread and keep it alive for three pages looking for advice on your code, only to ignore it and then explicitly state that you view conventions to be trivial?

    I advise everyone to quit replying, you're wasting your time...
    Salem likes this.

  8. #38
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    Arguing won't help me, so why would I put effort into that, your smarter than me, I would have to be a fool to argue with somebody as smart as you. And thank you for pointing out the code should be self explanatory, I will look at the names and comments to make them clearer.

  9. #39
    Registered User
    Join Date
    Oct 2006
    Posts
    2,294
    Quote Originally Posted by jeremy duncan View Post
    Arguing won't help me, so why would I put effort into that, your smarter than me, I would have to be a fool to argue with somebody as smart as you. And thank you for pointing out the code should be self explanatory, I will look at the names and comments to make them clearer.
    actually, nothing will help you, so long as you ignore the help that is offered.
    Salem likes this.

  10. #40
    Registered User
    Join Date
    May 2009
    Posts
    2,514
    Quote Originally Posted by rags_to_riches View Post
    Troll, or Aspie...you decide!
    I vote Aspie.

    I just read his post on a AI site My artificial intelligence theory version 8, help me out codesimian or asimov1 Forums

    Note: I still have only a slight idea on what he is trying to do.

    Tim S.

    PS: I hope my posts are easier to understand than his post.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  11. #41
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,295
    Thanks for that link. I can see now that there's just no helping him to program. His mind is clearly constantly filled with nonsensical thoughts. After reading about "Aspie", that sounds as likely as anything.

    Sorry Jeremy, I know your idea probably sounds perfectly sensible to you, but unfortunately you are the only one that thinks the way you do.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  12. #42
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    OK. Thank you.

  13. #43
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,176
    ^_^;

    Wow.

    As a huge fan of nonsense in all its genre, I love this guy.

    I also can't help but be a little afraid of the results if ever lines his thoughts up before firing them out.

    Soma

  14. #44
    Registered User
    Join Date
    Apr 2011
    Posts
    229
    So, since you kind people like to post in this thread for random comments that have nothing to do with coding. I decided to post some more code, here is my newest function I made, its the findMatch function.

    btw, are you personality cops who study people to see their inner workings of their mind? So much personality quiz's and personality comments.

    Here's the newest function;

    Code:
    void findMatch(){
        string temp1;
        string temp2;
        int count1 = 0;
        int countResult = 0;
        vector<string> text_file1;
    
        std::ifstream hfin1("holdSentence.txt", fstream::app), fin2("holdDatabase.txt", fstream::app);
        if (!hfin1 || !fin2) { std::cerr<<"file error\n"; std::exit(1); }
    
        getline( hfin1, temp1 );
    
        while( getline( fin2, temp2 ) ){
    
            for (int a=0;a < temp2.length();a++){
                if(temp1[a] == '1'){
                    for (int b=0;b < temp1.length();b++){
    
                        if(temp1[a] == temp2[b]){    // second argument of substr is length, not end.
                            count1++;
                        }
                        else{
                            continue;
                        }
                        if(count1 > 0 && countResult == 0 && (temp1 != temp2)){
                        cout << endl << temp2 << endl;
                        countResult++;
                        }
                    }
                }
            }
    
            text_file1.push_back( temp2 );
        }
    
        hfin1.close();
        fin2.close();
    
    }
    And just to make my own random comment, here it is;
    The Six Million Dollar Man TV Intro - YouTube

    Guess what Im saying with this youtube video and all your posts about my bad coding practice.

  15. #45
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,176
    *sigh*

    Still using `temp1' and `count1' and such. Why? What form of data do you expect the string to contain? What is being counted? These things are meaningful.

    Dude, how are you not getting this? This thread degenerated into this silliness because you've made it clear that you aren't interested in learning how to code from us. Strangely, that is exactly why the regulars offer up some of their time at this thread.

    If you don't want to deal with our standard so that we can process what you are doing so that we might help you just leave; the regulars are for now mostly being playful, but your aren't going to get much until we can understand what you are doing and why.

    Guess what Im saying with this youtube video and all your posts about my bad coding practice.
    Don't be shy! We all wanted to bang Lee Majors; there is even a song about it.

    Soma

Page 3 of 5 FirstFirst 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic memory and realloc(), freeing memory
    By C_Sparky in forum C Programming
    Replies: 6
    Last Post: 10-06-2010, 07:55 PM
  2. Am I freeing up the memory used in my program?
    By abrownin in forum C++ Programming
    Replies: 6
    Last Post: 05-04-2010, 03:13 AM
  3. Freeing memory
    By vbdave78 in forum C Programming
    Replies: 7
    Last Post: 11-18-2009, 11:56 AM
  4. Freeing memory
    By C_ntua in forum C Programming
    Replies: 17
    Last Post: 06-29-2008, 04:42 AM
  5. Freeing memory necessary?
    By Snip in forum C Programming
    Replies: 3
    Last Post: 11-05-2005, 06:01 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21