Clearing entire string with strcpy()?
#1

PHP код:
new str[32];
strcpy(str"\0");
strcpy(str"");
strcpy(strEOS); 
Are them correct? I am planning to use the same string again after formatting it.
Reply
#2

strclr
Reply
#3

Thank you!
Reply
#4

Just do str[0] = '\0', there's no need to overwrite the entire array and just adds an unneccessary overhead.
C-style strings should be always ended with an EOS ('\0), that's how all string manipulating functions work. strlen() counts characters until it finds a \0

And anyway, if you use format() there's no need to do this because it overwrites the entire string with newly formatted one anyway, you need to use that only if you want to for example use strins()
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)