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.
String connection in Unix/c++
Name: LaoMa Date: September 18, 2002 at 19:27:40 Pacific OS: Unix/Linux CPU/Ram: 256M
Comment:
Hi,I wonder how to connect 2 strings in c++ under Unix? I tried strcat,and the code got stuck(no compiling error,though). This is what I'm doing: char* s1="bin"; char* s2="***"; ... cout<simply doesn't work! The execution stops at the strcat.
Name: cup Date: September 19, 2002 at 14:18:58 Pacific
Reply:
You need to allocate space if you are going to do it the C way. There is a string type in C++.
#include // note not string.h #include using namespace std; main () { string s1 = "bin "; string s2 = "liner";
string s3 = s1 + s2;
cout << s3 << endl;
return 0; }
Should give you "bin liner"
0
Response Number 2
Name: cup Date: September 19, 2002 at 14:19:58 Pacific
Reply:
The includes were
string iostream
There is a problem with angle brackets in this forum.
0
Response Number 3
Name: LaoMa Date: September 19, 2002 at 19:57:01 Pacific
Reply:
Got it.Thanks. Sorry another basic question: what's the essential difference between string and char* or char[]? For example,if I define char[20] path,then assign "/bin/" to it,the compiler complains that the constant char[5] doesn't match the string.
Summary: Hi, I don't know how to do the following because I don't know how to use the string array in C++. Please Help!!! Thanx! #include <iostream.h> #include <string.h> class pizza { private: char**...
Summary: Hi. There are two ways (that i know of) to connect using DSN-Less connection in java. First way (for MS Access): Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String myDB = "jdbc:odbc:Driver={Microso...