Add a word to a string

How do I do to add a word (for example: car) the variable X[100] in the middle of the program?

X='car'

wont work :S
use double quotes x="car";
that will set x to "car", to add words use strcat() http://www.cplusplus.com/reference/clibrary/cstring/strcat.html
or the string class http://www.cplusplus.com/reference/string/string/
Thanks a lot,
I made it work with


char x[20]
(...)
strcpy(x,"car");

:D
Also take a look at strcat().

;-)
Look at strcat() strcpy()
;)
IMO. snprintf() or strncpy() is the better one to use. strcpy() and strcat() is leaving yourself open to buffer overflows.
Topic archived. No new replies allowed.