> On 11/11/2009 08:13 PM, Roland Plüss wrote: >> Another solution would be "sprintf(&buffer[0], ... )" >> which is again valid since&buffer[0] is of type "char*". > > &buffer[0] is exactly the same as buffer... the equivalence between > pointers and arrays is quite basic C and C++, try it. :-) In fact not. Go compile the version with buffer only. I'm using 4.x type compilers ( as maybe older ones are not strict enough as they should be ) and all versions I used so far bail out on this one. In all my code I use therefore the proper casting as the other way of writing it is in fact not correct. The reason is that "char*" tells the compiler that a null terminated string is expected. buffer[50] on the other hand is a fixed size string without null termination. It is therefore fully correct to disallow a direct conversion of one to the other since this conversion is highly likely to cause an error somewhere down the line ( missing null termination => segv ). It's anyways something one should not grow accustomed to since it is a dangerous mangling ( I still have a few places where I use this mangling... I know I'm a bad boy :P )
-- Yours sincerely Plüss Roland Leader and Head Programmer - Game: Epsylon ( http://epsylon.rptd.ch/ , http://www.moddb.com/games/4057/epsylon ) - Game Engine: Drag(en)gine ( http://dragengine.rptd.ch , http://www.moddb.com/engines/9/dragengine ) - Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
signature.asc
Description: OpenPGP digital signature
_______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
