Thread: couting unwanted garbage

  1. #1
    Registered User lord's Avatar
    Join Date
    Dec 2006
    Posts
    61

    couting unwanted garbage

    I'm not sure why but both my functions are couting garbage on certain elements for only a temporary period of time. I can't figure it out. Is it the way I am initializing the vectors? It is happening in both my functions but not in a similar third function (not shown)... Any ideas?




    CODE: http://pastebin.com/d1483aeeb
    Last edited by lord; 01-18-2009 at 10:07 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Perhaps
    default : hexadecimal.push_back( charRemainder + '0' );

    Also, the while loop should continue until number is zero
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User lord's Avatar
    Join Date
    Dec 2006
    Posts
    61
    CODE: http://pastebin.com/d425b7541

    I've uploaded all my code and commented on the lines where garbage is coming out.

    It didn't seem to help when added + '0' to the switch statement. Maybe if someone can run the code they will be able to see the issue better...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    I'd prefer the code here personally.
    pastebin (and similar) delete code after a time period.

    That maybe nice for you, but this thread wouldn't make any sense after your code has gone.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User lord's Avatar
    Join Date
    Dec 2006
    Posts
    61
    error was found finally in this statement:
    Code:
    cout<<"0x "<<hexadecimal[1]<<" "<<hexadecimal[0]<<cout<<"\t";

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Garbage Collector, Managed Heap etc.
    By mynickmynick in forum C Programming
    Replies: 2
    Last Post: 08-07-2008, 12:42 PM
  2. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  3. Garbage Collection is not so complicated
    By Nalpdii in forum C Programming
    Replies: 2
    Last Post: 10-07-2007, 11:34 PM
  4. C++ Garbage Collection
    By vaibhav in forum C++ Programming
    Replies: 1
    Last Post: 11-27-2005, 10:26 AM
  5. Garbage Collection
    By Orborde in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2005, 11:18 PM