Clearing entire string with strcpy()?
#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


Messages In This Thread
Clearing entire string with strcpy()? - by v1k1nG - 14.11.2018, 15:46
Re: Clearing entire string with strcpy()? - by Freaksken - 14.11.2018, 16:03
Re: Clearing entire string with strcpy()? - by v1k1nG - 14.11.2018, 16:06
Re: Clearing entire string with strcpy()? - by dotSILENT - 14.11.2018, 16:22

Forum Jump:


Users browsing this thread: 3 Guest(s)