![]() |
|
#1
|
||||
|
||||
malloc functionI've tried to use malloc function for dynamic memory allocation since i will be using very large input data.unfortunately, i've got the error like below.could anyone tell me how to solve the error?
Cannot convert void * to int * Last edited by JdS : 18-May-2004 at 05:54.
Reason: fixed typo in title
|
|
#2
|
||||
|
||||
|
Hi Rosmayati,
just like your other question, you posted the error but not the source codes.. in order to help you figure out what the problem is, you should post the codes that is causing you the error.. __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#3
|
||||
|
||||
|
this is the source code
CPP / C++ / C Code:
Last edited by JdS : 18-May-2004 at 05:55.
Reason: Please enclose c code in [c] & [/c] for syntax highlighting
|
|
#4
|
||||
|
||||
|
the line here is the problem:
CPP / C++ / C Code:
try casting like this to correct it: CPP / C++ / C Code:
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#5
|
||||
|
||||
|
I believe the problem is you are compiling your program as a C++ file, not a C file. In C you are not supposed to specify the type returned from malloc(). When I compile it, your original code works fine. When I compile it with a .cpp extension, I get the same error you do.
Look at your compiler's switches and add the switch that specifies C-compilation. Or if your file ends in .cpp, change it to .c __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#6
|
||||
|
||||
|
Okey, thanks for the solution. really appreciate it..
|
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| new to C, need an explanation | andre | C Programming Language | 18 | 23-Mar-2004 11:09 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The