POV-Ray : Newsgroups : povray.off-topic : You lose some... : Re: You lose some... Server Time
7 Sep 2024 03:23:05 EDT (-0400)
  Re: You lose some...  
From: Alain
Date: 5 Oct 2008 17:31:07
Message: <48e9321b$1@news.povray.org>
Orchid XP v8 nous illumina en ce 2008-10-04 14:37 -->
> Hmm, and I though everything was going so well. :-/
> 
> 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;
>   }
> 
> "Unhandled exception at 0x00414166 in Huffman01.exe: 0xC0000005: Access 
> violation reading location 0x00000004."
> 
> The code looks fine to me - but what I do know?
> 
Maybe you have an uninitialised pointer.

Do you get any output? If you don't, it mean that the variable "c" don't get 
initialised properly.
Look at the caller. Maybe the variable that is supposed to be passed is in fact 
a null, or an uninitialised pointer, or maybe a constant.

-- 
Alain
-------------------------------------------------
"The way England treats her prisoners, she doesn't deserve to have any." 
        --Oscar Wilde


Post a reply to this message

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