POV-Ray : Newsgroups : povray.off-topic : You lose some... : Re: You lose some... Server Time
6 Sep 2024 21:19:58 EDT (-0400)
  Re: You lose some...  
From: Warp
Date: 4 Oct 2008 15:51:54
Message: <48e7c95a@news.povray.org>
Orchid XP v8 <voi### [at] devnull> wrote:
> OK, any C++ experts have any idea why this code snippet causes my 
> program to crash at runtime?

>    typedef std::vector<bool> Codeword;

>    std::string codeword(const Codeword &c)
>    {
>      std::string out;

>      for (unsigned int i=0; i<c.size(); i++)
>        if (c[i]) out.append("1"); else out.append("0");

>      return out;
>    }

  I can't see anything wrong with it, and I tried it and there was
nothing wrong with it. The error must be somewhere else.

  If you are running it in linux, try running it using valgrind (if you
don't have it, install it; it's essential). In other words:

valgrind ./yourprogram

  If will tell you if you have some out-of-bounds access or memory leaks.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.