TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Adam Fitzpatrick
from: Paul Edwards
date: 1996-07-01 16:49:42
subject: Find a word

FA> char *txt;char *pat;char *ptr;
FA> txt = (char*) malloc(strlen(buf)+1);
FA> pat = (char*) malloc(strlen(wrd)+1);

DN>Just out of interest, why cast the return from malloc()? If it is
DN>because it has no prototype, then you should do the /correct/ thing
DN>and include stdlib.h.

AF> Eh? I thought it was because malloc returns a void*, and most compilers 
AF> will give you a warning because a char* is different to a void*.

"void *" is designed to "match any pointer", and you
can freely convert from "void *" to any other data pointer, there
is nothing suspicious about it, so there's no need for a warning.  In C++
they decided to tighten that up.  BFN.  Paul.
@EOT:

---
* Origin: X (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.