hi, i have the following code... im just wondering if what i did was a good way to get the outcome.
Code:/* lets assume userinput = "hello" */ char address[1000] = {0, '/'}; strcat(address, userinput); /* address is now /hello */
hi, i have the following code... im just wondering if what i did was a good way to get the outcome.
Code:/* lets assume userinput = "hello" */ char address[1000] = {0, '/'}; strcat(address, userinput); /* address is now /hello */
address will be "Hello", since the '/' is after a 0, so the address variable is essentialy the same as "" (empty string).
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
icic so when it detects the 0, it interprets it as end of string.
Correct. To initialize the address array, you can code
They are all the same. The backslash is called an escape character.Code:char address[1000] = {'\0'}; or char address[1000] = '\0' ; or char address[1000] = 0 ;
Mainframe assembler programmer by trade. C coder when I can.
thanks