>>1
First, you aren't allocating enough space for the string. They're zero-terminated, so what you should have is name = new char[strlen(inname) + 1]; -- also drop the sizeof(char) because array new already allocates the type in question rather than malloc-style bytes.
Second, just use the C++ std::string class. Not having to do string handling yourself is worth the efficiency penalty... long as you're using C++ anyway...
Name:
Anonymous2007-09-10 22:08 ID:Dp5Jfevu
maybe he's writing the class as an excersise. So there is little point to use the standard. let him reinvent the wheel.
>>11
Then let him fucking figure it out on his own as he should and not bitch and moan about his own incompetence here while begging for help from his Personal Army(tm).
To be C++ compliant, one should use std::string. But for some crappy reason I can't remember well (something to do with GNU or GPL license or something) some compilers will link statically to the standard library. This gives 400KB+ executable file size for a fucking Hello World. As far as I know this is the case for the GNU c++ compiler. Borland c++ and Visual c++ compiler both provide a dynamic standard library dll (libstdc++.dll or something)
Name:
Anonymous2007-09-11 2:30 ID:1cMh3ula
>>19
Not only do you get massive executables, but you also have to install a 2gb IDE just to compile them.
Name:
Anonymous2007-09-11 2:45 ID:FclbgyED
>>20
erm, dude, he was saying that the xbawks hueg 2gb IDEs make smaller executables than gcc.
>>23
Me was talking about Windows environment. Because Linux is GNU, maybe they can link dynamically. By doing the same in windows I get 487676 Bytes hello.exe
Name:
Anonymous2007-09-11 9:05 ID:bCN3WPHN
>>25
Wasn't MinGW's point to link statically or something like that?
Name:
Anonymous2007-09-11 11:32 ID:1fd632Jb
>>23
Dude, you forgot to strip your executable. No fair comparing sizes when like half is symbol tables and so forth.
Name:
Anonymous2007-09-11 11:55 ID:5GYgZE+H
stripping only cut it to 270KB while >>23 not stripping it in Linux gets 8KB
Name:
Anonymous2007-09-11 12:18 ID:1fd632Jb
Yeah, I meant that in Linux stripping it would bring the exe down to some 5-odd KiB...
Still, that's what one gets by linking standard libraries statically. Win32's dynamic library system is rather the polar opposite to state of the art.