www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/07/06:45:24

From: Jedediah Smith <jedediah AT interlog DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Allocating vars in middle of function (possible DJGPP bug)
Date: Tue, 07 Jul 1998 07:56:33 -0700
Organization: Interlog Internet Services
Lines: 29
Message-ID: <35A23721.FAB@interlog.com>
NNTP-Posting-Host: 209-20-0-74.dialin.interlog.com
NNTP-Posting-Time: 7 Jul 1998 08:53:30 GMT
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In the middle of a function I had something like this:


MyFunction()
{
   ...

   {
      char myString[20];

      // myString is used only in here

   }

   ...
}

My intention was to have myString allocated at the beginning of the code
block and deallocated at the end. Clearly myString was not getting
allocated at all because I was getting protection faults in the code
that used it. When I moved the myString declaration to the beginning of
the function, it worked fine. Should myString have been allocated in the
above example, or do I have my C++ syntax wrong?

-- 

      .....
        :edediah
      :.:

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019