www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/22/08:16:25

From: zidharta AT yahoo DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: mistery of variable scope, can any one explain?
Date: Sun, 22 Aug 1999 10:36:57 GMT
Organization: Deja.com - Share what you know. Learn what you don't.
Lines: 32
Message-ID: <7pojs9$348$1@nnrp1.deja.com>
NNTP-Posting-Host: 203.109.254.190
X-Article-Creation-Date: Sun Aug 22 10:36:57 1999 GMT
X-Http-User-Agent: Mozilla/4.08 [en] (Win95; I)
X-Http-Proxy: 1.0 x37.deja.com:80 (Squid/1.1.22) for client 203.109.254.190
X-MyDeja-Info: XMYDJUIDsidxidzid
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I was doing a C++ bitmap loader program when I found this ...
take attention on the variable pix ...
------------CODE----------------
#include statement ...
char *pix;

int main() {
//.......
loadBitmap();
}

int loadBitmap() {
//.......

pix = new char[...];
//load bitmap to pix..
}

----------------------------------

the code above wont display the bitmap ....
but if I declare
char* pix = new char[...] straight away on the global scope area ... it
will work ... why??... could anyone explain ..??
thanks in advance


Sid


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

- Raw text -


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