Silly errors

This is a discussion on Silly errors within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Have you ever looked at a piece of code you wrote a week ago and seen this: Code: double x ...

  1. #1
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493

    Silly errors

    Have you ever looked at a piece of code you wrote a week ago and seen this:
    Code:
    double x = sum();
    if (contains_factor())
      x += 0;
    else
      x += coefficient();

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Well its not quite the same but for some reason when i wrote my newbie txt RPG i incremented x and y positions like this:

    Code:
    user_x = user_x++;
    Now i look through code from even a few months ago and im like wtf was i thinking here?? Im getting better at debugging and finding better routes though.

  3. #3
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    I wrote some code really quickly the other day with STL lists. When I tried to compile it, I realized that I had for some reason tried incrementing the list in a for loop instead of the iterator.

    Anything I write quickly usually has a few mistakes on the order of, "WTF was I thinking."
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    I started to learn C#, then a few days later I thought:
    "WTF was I thinking".

  5. #5
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    It has been a while since I wrote this code and I finally dare posting it:
    Code:
    //DrawText v2.0
    DxEngine* DxEngine::DrawText(int x, int y,const Color& c,TCHAR *szFormat, ...)
    {
        TCHAR *szBuffer=new char[strlen(szFormat)+512];// Large buffer for very long text
    
        va_list pArgs;
        va_start(pArgs, szFormat);
        vsprintf(szBuffer, szFormat, pArgs);
        va_end(pArgs);
    
        HDC hdc;
    
        if(lpddsback->GetDC(&hdc)==DD_OK)
        {
            SelectObject(hdc,hFont);
            SetTextColor(hdc, RGB(c.r,c.g,c.b));
            SetBkMode(hdc, TRANSPARENT);
            TextOut(hdc, x, y, szBuffer, strlen(szBuffer));
            lpddsback->ReleaseDC(hdc);
        }
    
     return this;
    
     delete[] szBuffer;
    }
    My game crashed after five minutes constantly and when I added debug info to the screen it only crashed faster.
    I was puzzled. :)
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  6. #6
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Aha! Here's the code. Yes... I must've been rather tired.

    Code:
    std::list<QString> cont;
    // ... Populate cont ...
    
    std::list<QString>::const_iterator it;
    
    for(it = cont.begin(); cont != cont.end(); ++cont) :rolleyes: 
    {
       // Do stuff...
    }
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  7. #7
    Registered User
    Join Date
    Jun 2003
    Posts
    14
    Hey Brian ... how's the C# learning coming along?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. best download site
    By gooddevil in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-20-2004, 10:36 PM
  3. Sreen Resolution Statistics?
    By Davros in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 04-26-2004, 02:33 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  5. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM

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