inherit
8696
0
Jan 3, 2024 23:35:38 GMT -8
The Dark Knight
Hope is a dangerous thing.
38,980
April 2003
avtar
|
Post by The Dark Knight on Aug 3, 2005 3:47:19 GMT -8
|
|
inherit
g4m3 0v3r
771
0
Jul 18, 2011 18:29:23 GMT -8
David (Monty)
3,669
December 1999
mbarker22
|
Post by David (Monty) on Aug 3, 2005 19:04:53 GMT -8
Why not just use the standard C functions strncpy and strncat? Or better yet, use C++ standard strings instead of C char arrays: #include <iostream> #include <string>
using namespace std; // for simpilicity in example only, I would not usually use this
int main() { string str1; string str2; string str3; cout << "Enter First String : "; getline(cin, str1); cout << "Enter Second String: "; getline(cin, str2); str3 = str1 + str2; cout << "Concatenated String is : " << str3 << endl; cin.get(); return 0; } Advantages: No array bounds to worry about, so it's impossible to enter too large of a string (until you run out of system memory) No special functions for copying and concatenating, just use + and = Easy to use additional built-in functions, like for searching and parsing strings Should work in any modern C++ compiler
|
|
inherit
8696
0
Jan 3, 2024 23:35:38 GMT -8
The Dark Knight
Hope is a dangerous thing.
38,980
April 2003
avtar
|
Post by The Dark Knight on Aug 4, 2005 3:23:01 GMT -8
The person wanted to see the logic of the entire thing and arrays.
It's the beauty of old school programming, it requires thinking.
|
|