yeah, it was encrypted with 128bit RSA algo. Its great that you could decrypt it :) .Just kidding.. Its neither encrypted nor a question from an interview. I had to write some code today and I re written the code in different way also. But I gor a doubt if this code is valid and wanted a confirmation.
Raj Prathap
Posts
-
Is this c/c++ code valid -
Is this c/c++ code validI'm not new to C++ :omg: . Today I had to write some code which includes swith cases, but case lables are valid in only some conditions (depending on the device type). I was not completly sure that the code is invalid, and wrote a test pgm in vs2k3, and it worked fine. Before checking in, wanted a confirmation.
-
Is this c/c++ code valid:) Thanks for the reply. Please post your choice.
-
Is this c/c++ code validint i = 10; int k = 100; switch(i) { case 0: cout << "case 0" <<endl; break; if(k == 100) { case 10: cout <<"The device type is 100 so attribute 10 is valid"<<endl; break; } else { case 100: cout <<"attribute 100 is there" << endl; break; } break; default: cout <<"default"<<endl; }
Please confirm whether 'if' could be placed inside a switch statement. Pratap -
Sockets and multithreading - doubtAll, I have a doubt whether two different threads can be working on a same socket descriptor(handle in windows terminology)? Please go through the following scenario: We have one device which supports TCP/IP: 1. Responds to the requests 2. Sends notifications, incase any events Can I have two threads one for continuesly wait to receive the notifications & response and another for sending the requests to the panel? Could someone please provide (link will suffice)a good design for this class. Best Regards, Pratap
-
DWORD dw='pp' is valid in VC++ 6.0 :(Sorry for replying after so many days.. it was Deevali in India and I was in vacation. Thanks a lot for the link. It was quite helpful. Pratap
-
DWORD dw='pp' is valid in VC++ 6.0 :(I'm sorry There was a mistake in calculating the value of 0x7070 in decimal format. The value is 0x7070 only!! Thanks a lot for your support!! could you kindly specify that the statement DWORD dw='pp'; is valid in all platforms!! I'm googling for it, but no success!!
-
DWORD dw='pp' is valid in VC++ 6.0 :(No! The DWORD value is coming as 28784 in my machine
-
CString to TCHAR & TCHAR to CStringI'm not getting what you are trying to do with the code. CString is just a wrapper for TCHAR. That is CString has a member variable like below. CString { private: TCHAR *m_buf; //Several other stuffs! }; if your intention is to construct another CString from the edit box contents then CString messageback(message) will suffice. to get the pointer to member variable m_buf(member variable name might not be exact) by using GetBuffer() method. pratap
-
About Memory initializationUse char *str = malloc(n*sizeof(char)); if str is local, then foo(int n) { char str[n]; } is also valid in vc6.0 Regards, Pratap
-
Read Console OutputIO redirection might help you. in command prompt, if abcd.bat is the batch file then I'd gove the command abcd.bat >output.txt hope that was helpful.
-
DWORD dw='pp' is valid in VC++ 6.0 :(I'm using VS6.0. I was going through the code which was written nearly 3 years before. I have seen one statement like said in the subject DWORD dw='pp'; I was not aware that is a valid statement. And still I'm not clear what will be the value of dw. I calculated if it is equivalent to ('p'<<8 + 'p') but no success. Can some kindly clarify me on whether two characters in single cotes is valid in C/C++ or it is valid only in VC++. If valid in VC++, how would the value is calculated for the literal in two cotes. regards, Pratap
-
why CArray::GetSize() returns INT_PTRHi All, Please explain me why CArray::GetSize() returns an INT_PTR. When I see the documentation regarding the function, it says returns the number of elements in the array. Number of elements are int/long. I could not understand why is this INT_PTR. In VS2k3, the compiler throws a warning. In VC6.0 there is no warning. Regards, Pratap
-
Doubt on CString and BSTR LPWSTRThanks. The link provided is really helpful. I was not clear about the parts of the BSTR i.e length+data+terminator. I used think terminator would not be there since the length is already there. Any ways with the link to MSDN article, all doubts are cleared. Thanks a ton. /pratap
-
Doubt on CString and BSTR LPWSTRHi All, I have on basic doubt. In windows environment both BSTR and LPWSTR are typedef ed to unsigned short *. But the contents in that pointer are different. BSTR is a wide char string with length in the first byte. LPWSTR is a null terminated string. But,
CString str; LPWSTR lpw = L"lpwstr"; BSTR bst = AllocSysString("bstr"); str = lpw; //how at runtime identified whether first char is length or actual data? str = bsw; //Both of the statements work fine
The code works fine, and behaves as we expect. My doubt is how at run time the decision on the first byte is decided? i.e whether the first byte is the data or the length?? how the compiler identifies. Thanks and regards, Raja Pratap -
returning array of BSTRs from the COM componentThanks a ton Mike, working and its very easy to code.
-
Returning an array of BSTR from the COM ComponentI Tried with BSTR**, could not succeed. Only first string comes, since the marshaller considers only the first string, since length is not mentioned. I got a hint from one of CP members to use SAFEARRAY(BSTR)* that worked fine.
-
Returning an array of BSTR from the COM ComponentHi, I have a method which has to return the array of BSTRs. I'm giving the method here, please let me know if I'm doing anything wrong.
HRESULT Login([in] BSTR UserName, [in] BSTR Password, int maxUsrCnt , [out]int *UsrCnt, [out, length_is(,*UsrCnt), size_is(,maxUsrCnt)] BSTR *LoggedUsers);
the size of the array to be returned is not known at the time of calling. When I use this method, the first string is coming properly, but other strings are not coming. Please suggest an answer. Regards, Raja Pratap -
returning array of BSTRs from the COM componentHi, I have a method which has to return the array of BSTRs. I'm giving the method here, please let me know if I'm doing anything wrong.
HRESULT Login([in] BSTR UserName, [in] BSTR Password, int maxUsrCnt , [out]int *UsrCnt, [out, length_is(,*UsrCnt), size_is(,maxUsrCnt)] BSTR *LoggedUsers);
the size of the array to be returned is not known at the time of calling. When I use this method, the first string is coming properly, but other strings are not coming. Please suggest an answer. Regards, Raja Pratap -
Problem facing with connection pointsThe problem got soleved. We have to make the server free threaded and make the class implementing the interface singleton and we need to in _tWinMain.. make sure that CoInitializeEx gets called. Just trial and error caused a break through. Thanks and regards, Raja Pratap