Now I obviously do not know how big the buffer will be, the problem is if i set buffer, everything after the actual content is trash.
How would I fix that?
Like I wanna see only the actual content and not the jibberish after it.
e// nevermind, I just found out that recv returns the size..
The documentation for recv[^] shows the prototype looks something like this:
__in SOCKET s,
__out char *buf,
__in int len,
__in int flags
It describes the return value like this:
If no error occurs, recv returns the number of bytes received and the buffer pointed to by the buf parameter will contain this data received. If the connection has been gracefully closed, the return value is zero.
Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
So what you have to do is add a NULL terminator and where you add it depends on how much data you recieved:
char hello = "hello?\n";
send(sock, hello, sizeof(hello), 0);
int res = recv(sock, buffer, sizeof(buffer)-1, 0); // -1 so we'll always have room for NULL terminator.if (res != SOCKET_ERROR)
buffer[res] = 0; // NULL terminate.
cout << buffer << endl;
hello guys... I have a file MyClass.cpp inwhich I declared a vector array. I then added some string data to it and want to access it in MyProjDlg.cpp. It is dialoged based app in vc6. Here it is
typedef vector<LPTSTR> StudentData;
//some code here...void someFunc()
//Now here in MyProjDlg.cpp...what should I do to access this vector array and //put that data in Listbox..here it is what I tried so far but no resultextern StudentData std;
//some loop to enter this data in listbox....for (int i=0; i<5; i++)
it is showing 7 defferent errors....any idea whats wrong that im doing?
You have defined StudentData with a typedef in MyClass.cpp, and then referenced it without definition in MyProjDlg.cpp. Please review the suggestions to your original question on this subject, and also read up on the use of the extern keyword.
[EDIT]Stephen Hewitt even gave you a complete solution to your problem here[^].[/EDIT]
Just say 'NO' to evaluated arguments for diadic functions! Ash
Option is, when you are using property page as a dialog,let the messages be handled by CDialog rather than cPropertyPage. Over-ride PreTranslateMessage for this purpose.
BOOL CMyPropPage::PreTranslateMessage(MSG* pMsg)
// when using as a propery page, //return CPropertyPage::PreTranslateMessage(pMsg);// when using as dialogreturn CDialog::PreTranslateMessage(pMsg);
If you are overriding OnCancel(), call CDialog::OnCancel() to dismiss the dialog on escape key.
please tell me how can i use Propetypage as dialog box.
This makes no sense. If you have a property sheet that contains one property page (i.e., tab), you effectively have a dialog box, albeit one that looks "oddly." Unless you have more than one page, just use a dialog box.