I know this is a basic question but I can’t seem to append a char string (\r\n) to another. I have tried using arrays (strcpy) and string objects but with no progress. To send a string to a Java applet I need to append the \r\n characters or it will just sit and wait for them. When I use a stirng with the c_str() function I get a
C:\ucdhb2\gaia\async_ssl\no4\basic.cpp|163|error: request for member
‘c_str’ in ‘readit’, which is of non-class type ‘std::string*’|
error. Any help would be appreciated.
char readit[45];
cin >> readit;
strcpy( readit, "\r\n" );
SSL_write( ssl, readit, strlen(readit)); // This doesn't work
// SSL_write( ssl, "this works\n\r", strlen("this works\n\r")); // This works
A
stringshould be what you need.As other commentators have noted, your sample code needed to use
strcatrather thanstrcpy. But, if you go with usingchararrays, you will need to check for buffer overflow.std::stringwon’t overflow.