#include#include CString ReadLineFromFile(const CString& filename) { std::ifstream file(filename); CString line; std::getline(file, line.GetBufferSetLength(1024), '\n'); line.ReleaseBuffer(); return line; }
#includeThis example uses the Windows Sockets API to read a string from a socket. The CString object is used to store the string read from the socket. Package/library: The CString ReadFromStream function is part of the MFC library, which is included with the Microsoft Visual C++ development environment.CString ReadStringFromSocket(SOCKET socket) { char buffer[1024]; int numBytes = recv(socket, buffer, sizeof(buffer), 0); buffer[numBytes] = '\0'; return CString(buffer); }