couting unwanted garbage

This is a discussion on couting unwanted garbage within the C++ Programming forums, part of the General Programming Boards category; I'm not sure why but both my functions are couting garbage on certain elements for only a temporary period of ...

  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 09:07 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 09:26 AM
  5. Garbage Collection
    By Orborde in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2005, 11:18 PM

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