Hi, i'm learning the OOP and C++ at home. Now I'm at the Constructor - destructor stuff, and while going thru some exercises i got an error. Now please look at the code and help me. Thanks! :kosta:
Code:
#include <iostream> At the end of execution i get this problem: http://img80.echo.cx/img80/5581/probi0eu.th.gif I also know that the program worked fine before creating a destructor. :wall: :cheers: |
the loops you use to copy a string are flawed.
for(i=strlen(p);i=0;i--) Then it will be allright. |
Quote:
Code:
for(i=strlen(p);i>=0;i--) Thanks Data! :ok: :kosta: Now you have honour off closeing this topic. ... :wall: |
as you allready include cstring...
why not do a strcpy(pok,p); Oh well That's outside the scope of this thread. |
Quote:
|
I doubt it.
the libc functions are quite optimized. (they could have been written in pure asm). Don't try to reinvent the wheel. as there smarter systems for copying a string. like while ((a[i]=b[i])) i++; and not to mention that strlen takes computing power as well. (strcpy probably doesn't check for the length.(like that while system.) |
Cool, great man....
...so can i PM you if i have another problem.... ??? :blink: |
as long as you keep the source that demostrates the problem small and readable.
|
Quote:
|
The current time is 03:44 AM (GMT) |
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.