Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Sun, 12 Oct 2008 14:45:19 -0400
"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:213AA21B-76AF-4503-B80F-D0C9307F185B@xxxxxxxxxxxxx
Okay, I have entered the code in VC++ and an error points to the same
line of code:
*obj_PASSCODE = malloc (sizeof (PASSCODE));
The error is:
c:\_DTS_PROGRAMMING\C_PROGRAMMING\c\TEST_4\Test_1.cpp(70): error
C2440: 'type cast' : cannot convert from 'void *' to 'PASSCODE'
malloc() returns void*. Unlike C, there's no implicit conversion in C++
from void* to other pointer types. If you want this code to be valid C++
as well as C, make it
*obj_PASSCODE = (PASSCODE*)malloc(sizeof (PASSCODE));
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Barry Schwarz
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Robby
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- References:
- Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Robby
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Giovanni Dicanio
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Giovanni Dicanio
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Robby
- Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Prev by Date: Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Next by Date: error C3861: 'glVertix2i': identifier not found
- Previous by thread: Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Next by thread: Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Index(es):
Relevant Pages
|