POV-Ray : Newsgroups : povray.off-topic : You lose some... Server Time
7 Sep 2024 05:09:00 EDT (-0400)
  You lose some... (Message 31 to 31 of 31)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Alain
Subject: Re: You lose some...
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

<<< Previous 10 Messages Goto Initial 10 Messages

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