| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Find a word |
> DN> Just out of interest, why cast the return from malloc()? If > DN> it is because it has no prototype, then you should do the > DN> /correct/ thing and include stdlib.h. > I have to cast it in Borland. In both TC2 and BC4 i'll get a > "cannot assign void* to char* error" otherwise Oh. Then disable C++ mode - you're compiling in C++, not C. > it'll happen with both > ANSI, or Borland extensions used C or C++. It won't happen in C mode. If it does, the compiler is broken. And Borland wasn't *that* broken last time I looked at it. > DN> Excuse my bent towards better readability :-) > And what's wrong with my codes' readability ? > Dammit, i've "accidently" cut the evidence :) :-) > I don't like strdup(), makes it a bit easy to forget to free the > string How so? What's the difference between using it and malloc? Library calls exist for a reason. strdup() is convenient and it avoids unnecessarily repeating code. There is no reason not to use it. > DN> Note the 'const' in the parameters. It is a good idea to > DN> define the interface to a function as clearly as possible, > DN> which is why const exists. It also allows you to use the > > I always thought the main functionality of a const was to keep the > variables constant. No, 'const' is an interface modifier. The /effect/ of using const pointers is to prevent the compiler from modifying whatever it points to, but that's the nature of the interface, and not really an expression of physical "constness" of a variable. For example, you could not use a "const char *" or "const char []" type as a parameter to your function. You'd have to cast away const, which is of course completely unnecessary. > i'd spend 90% of programming time there(being a DOS IDE). > BC4 does have it, so i'll have to keep it in mind, i normally do my > final compile with it.It tends to do a better optimize.Not on size. :) With Borland compilers, its "optimisation" isn't crash hot irrespective of the version. It's probably the most slothful of all the major commercial PC compilers in that respect, which is of course why it compiles comparatively quickly. --- MaltEd/2 1.0.b6* Origin: Unique Computing Pty Limited (3:632/348) SEEN-BY: 50/99 620/243 623/630 632/103 107 348 360 633/371 634/388 396 SEEN-BY: 635/301 502 503 506 544 639/252 711/401 409 410 413 430 808 809 932 SEEN-BY: 711/934 712/515 713/888 714/906 800/1 @PATH: 632/348 635/503 50/99 711/808 934 |
|
| 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™.