Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
c++ combine strings
Name: Mechanix2Go Date: December 13, 2005 at 03:05:49 Pacific OS: w2k sp3 CPU/Ram: PIII 933/256MB
Comment:
I need the syntax to combine strings. This doesn't work:
... and one more thing, if you want to overwrite any value assigned previously to the variable "name" then use "strcpy()" and "strncpy()" instead of "strcat()" and "strncat()" respectively on the first line ie the above code should be
1)
strcpy(name, first); strcat(name, last);
2)
strncpy(name, first, strlen(first)); strncat(name, last, strlen(last));
the first line in each code overwrites the variable "name" and combines "first" and "last" to form the new value for "name".
Summary: As Jim says, set the array to 0 #define PHRASE_MAX 100 char phrase[PHRASE_MAX]; memset (phrase, '\0', PHRASE_MAX); /* Get the input line */ gets (phrase); Or if you prefer C++/STL string phrase; getli...
Summary: Hey guys i have a project due in for my C++ class on monday and im almost finished and i just need some help on two issues. I am building an enigma machine, and i have all the code ready to input text...
Summary: I have two char strings in C and I am trying to compare them to each other in an if statement. This is what I have: char client_code[] = "mypass123"; char code_buf[9]; if (client_code != code_buf) { ...