GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-May-2008, 07:39
sapan_shah143 sapan_shah143 is offline
New Member
 
Join Date: May 2008
Posts: 11
sapan_shah143 is on a distinguished road

Run-Time Check Failure #3 - The variable 'bRecievedData' is being used without being


hi everyone,

i have written code for buffer as below. but is shows runtime error "Run-Time Check Failure #3 - The variable 'bRecievedData' is being used without being " .

and shows bad pointer. what should i do to remove this error.
i need help urgently

BYTE *bRecievedData; /* buffer for reciving data */

memset(bRecievedData,0,sizeof(bRecievedData));
  #2  
Old 07-May-2008, 08:00
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 440
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Run-Time Check Failure #3 - The variable 'bRecievedData' is being used without be


You should probably allocate memory for it before calling memset(). Is bReceivedData a single BYTE or and array or BYTEs?
  #3  
Old 07-May-2008, 21:46
sapan_shah143 sapan_shah143 is offline
New Member
 
Join Date: May 2008
Posts: 11
sapan_shah143 is on a distinguished road

Re: Run-Time Check Failure #3 - The variable 'bRecievedData' is being used without be


it is a single byte
  #4  
Old 12-May-2008, 03:48
sapan_shah143 sapan_shah143 is offline
New Member
 
Join Date: May 2008
Posts: 11
sapan_shah143 is on a distinguished road

Re: Run-Time Check Failure #3 - The variable 'bRecievedData' is being used without be


hi i have solved it. it is just because of pointer. it should be assigned to NULL
  #5  
Old 12-May-2008, 07:35
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 440
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Run-Time Check Failure #3 - The variable 'bRecievedData' is being used without be


Quote:
Originally Posted by sapan_shah143
hi i have solved it. it is just because of pointer. it should be assigned to NULL
Actually, you still need to allocate memory for it. It might "appear" to work, but it is not correct. Try this:


CPP / C++ / C Code:
BYTE *bRecievedData; /* buffer for reciving data */
bRecievedData = new BYTE;
memset(bRecievedData,0,sizeof(bRecievedData));
  #6  
Old 12-May-2008, 22:48
sapan_shah143 sapan_shah143 is offline
New Member
 
Join Date: May 2008
Posts: 11
sapan_shah143 is on a distinguished road

Re: Run-Time Check Failure #3 - The variable 'bRecievedData' is being used without be


thanks , i got it
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding check boxes to Dialog at run time manmfc MS Visual C++ / MFC Forum 2 30-Apr-2008 00:57
Life Time of Function static variable? ahbi82 C Programming Language 3 16-Oct-2007 01:24
constructors/classes mapes479 CPP / C++ Forum 3 19-Nov-2006 17:34
Need help understand function prototypes! Blstretch CPP / C++ Forum 20 25-Oct-2005 14:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:09.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.