|
me to want same coding . if u got it send to my mail plz..
by
vadivelu
9940294388
chennai
|
|
|
|
|
hi all
I have problem im my program,
I have:
<br />
string str_1, str_2;<br />
if( strcmp(str_1.data(),str_1.data()) == 0)<br />
{<br />
cout<<"equals";<br />
}<br />
else<br />
{<br />
cout<<"Not equals";<br />
}<br />
problem is that in 'str_1' and 'str_2' I have same text and rezult is "Not equals", can you help me and say how can I compeer two STL string's?
|
|
|
|
|
Hello,
If you refer to your STL implementation doc's, you should find that data(): "Returns a pointer to an array of characters, not necessarily null-terminated, representing the string's contents", so it's probably a bad idea to pass that to a function that expects 0-terminated 'strings'. You should use c_str() instead, if you want to use strcmp.
A better way, if you're just testing for equality, would be to use std::string's operator ==(), as in
if (str_1 == str_1)
HTH
Jonas
---
"Man will never be free until the last king is strangled with the entrails of the last priest". -- Denis Diderot
|
|
|
|
|
<br />
if (str_1 == str_1)<br />
?
there is not operator ==()
|
|
|
|
|
If you're using STL's std::string there is indeed an operator == .
Steve
|
|
|
|
|
In your example code you write
if( strcmp(str_1.data(),str_1.data()) == 0)
so I just went with the same comparison.
std::string has the == operator, please refer to your documentation. If your implementation doesn't, consider updating to a proper implementation.
You can also use str_1.compare(str_1) (or str_2 if it's just a type-o)
/J
---
"Man will never be free until the last king is strangled with the entrails of the last priest". -- Denis Diderot
|
|
|
|
|
thanks.
it help me.
|
|
|
|
|
Don’t do that! If you want to compare two string object use “str_1 == str_2”.
If you must use the C comparison function then use “strcmp(str_1.c_str(), str_2.c_str())”.
Of course the example you are giving will always be true, provide the system does not object, because both arguments are the same.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
TCHAR buffer [16384];
DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]);
BOOL bRes = InternetGetCookie(("http://www.codeproject.com"), NULL, (LPWSTR)buffer, &bufferSize);
DWORD ret;
if(bRes==FALSE)
{
ret = ::GetLastError();
CString str;
str.Format(_T("%d"),ret);
MessageBox(NULL,str,NULL,MB_OK);
MessageBox(NULL,_T("no items1"),NULL,MB_OK);
if (ret == ERROR_NO_MORE_ITEMS)
MessageBox(NULL,_T("no items"),NULL,MB_OK);
else if(ret == ERROR_INSUFFICIENT_BUFFER)
MessageBox(NULL,_T("insufficient buffer"),NULL,MB_OK);
else if(ret == ERROR_INVALID_PARAMETER)
MessageBox(NULL,_T("invalid parameters"),NULL,MB_OK);
}
else
{
MessageBox(NULL,buffer,NULL,MB_OK);
}
This code is displaying garbage value for buffer.But I need the cookie value.what to do?
|
|
|
|
|
rindam wrote: what to do?
First, stop posting your question multiple times.
Second, a previous reply already told you the data is encoded and gave you a link to read. If you want to develop software I suggest you stop typing questions into forums and start reading the documentation that is relevant to your task.
|
|
|
|
|
LPCSTR name="usrauth"; //name of the cookie
TCHAR buffer [16384];
DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]);
BOOL bRes = InternetGetCookieA(("http://www.mirracle.com"), name, (LPSTR)buffer, &bufferSize);
MessageBox(NULL,buffer,NULL,MB_OK);
This above code I am using to get the cookie value.But messagebox is not displaying the cookie value,it is displaying some garbage value.How to get the cookie value here?what is the mistake here
|
|
|
|
|
C:\Documents and Settings\'user'\Cookies
in this folder ise cookie-s in text files sow you can read cookies in noteped
"where the bar should change according to whether the user is logged in or logged out."
if cookie is set user is logged in and if it is't set he is logged out.
you must know that cookies have life time.
Example:
some cookies are deleteing wen you logged out, but some cookies "live" 50 minute( mail.ru example) or more.
in my site I am deletin cookies when user logged out.
|
|
|
|
|
InternetGetCookie function is always returning false.I am giving u the code here,can u plz tell me where the mistake is?
-------------------------------------------------------------------------------
char szURL[256]="http://www.mirracle.com";
LPWSTR lpszData = NULL; // buffer to hold the cookie data
DWORD dwSize=255; // variable to get the buffer size needed
LPCWSTR usrauth =NULL;
BOOL result=InternetGetCookie(szURL,usrauth,lpszData,&dwSize);
DWORD ret;
if(result==FALSE)
{
ret = GetLastError();
if (ret == ERROR_NO_MORE_ITEMS)
MessageBox(NULL,_T("no items"),NULL,MB_OK);
else if(ret == ERROR_INSUFFICIENT_BUFFER)
MessageBox(NULL,_T("insufficient buffer"),NULL,MB_OK);
else if(ret == ERROR_INVALID_PARAMETER)
MessageBox(NULL,_T("invalid parameters"),NULL,MB_OK);
}
else
{
MessageBox(NULL,lpszData,NULL,MB_OK);
}
The InternetGetCookie function is always returning false here and I am not being able to get the cookie value for this particular site.Plz help me.
|
|
|
|
|
The way you've specified the output buffer is wrong - YOU have to allocate that buffer - the function won't do it for you. At the moment, you're telling th efunction to put teh cookie data at address zero - always a bad idea.
This code seems to work (OK, I've used a different URL - just replace mine with yours):
TCHAR buffer [16384];
DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]);
BOOL bRes = InternetGetCookie(_T("http://www.codeproject.com"), 0, buffer, &bufferSize);
|
|
|
|
|
here also this function is returning false.whats the problem?
|
|
|
|
|
I have tried with the below code:
TCHAR buffer [16384];
DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]);
BOOL bRes = InternetGetCookieA(("http://www.mirracle.com"), name, (LPSTR)buffer, &bufferSize);
this code is working fine .but I need to get the cookie value,How can I get it?
|
|
|
|
|
The string in buffer is the value. It's stored in an encoded form, as described here[^]
|
|
|
|
|
Hi,
I would like to use bitwise operators (specifically, & and |) on a pair of std strings of equal length. At the moment I am simply iterating through both strings and carrying out the operation on each byte individually. However this seems a little inefficient to me, and I would prefer to use the bitwise operator on the whole string, as a chunk of memory.
Is it possible? Is there a more efficient way of doing it that iterating through the strings? The strings in question are quite long, a few thousand bytes.
Thanks for any ideas
Mick
|
|
|
|
|
mellib wrote: However this seems a little inefficient to me, and I would prefer to use the bitwise operator on the whole string, as a chunk of memory. mellib wrote: Is there a more efficient way of doing it that iterating through the strings?
The only efficiency you'll gain is in lines of code - the performance would be exactly the same - the only way you can apply a bitwise operator to a memory range is to iterate through it. You could iterate through the strings a longword at a time instead of a byte (although the only way of doing that probably makes unwarranted assumptions about std::string implementation details).
Seriously - measure the performance and determine if it has a serious impact on your code before trying to optimise.
|
|
|
|
|
Hi
I want to read cookie value for a particular site from VC++.My
project is an IE Toolbar which is using ATL,COM and not using MFC.I
need to get the cookie value for a site.I have tried with
internetGetCookie function,but everytime it is returning false.Can
anybody plz help me with some sample code?
|
|
|
|
|
Hi
I have developed an IE toolbar in ATL,COM,WTL and without using MFC.This toolbar is for a particular site.This is having a sign in button on clicking which user will be navigated to sign in page of our site.After signing in the toolbar will be changed,means it will be having some extra buttons on it.when the user will click logout,the toolbar will be back to its previous state.Means this is like yahoo toolbar.Upto this part I have made it perfect.I have done MySql database connectivity from my toolbar.Now the problem what I am facing is that:
if any user logs in our site and then he dose not do anything in the site for 20 minutes his session expires,means nothing will work in the site after idle 20 minutes,the user needs to sign in again.Now in that moment also I need to change the toolbar(I need to get the the toolbar in signed out state).How can I do it?Can anybody plz help me with some sample code?
|
|
|
|
|
Hello all,
Please help me..
I am trying to compile a code.
In debug mode compilation it is not showing any error.
but if I compile it in win32 Release MinDependency mode it is showing below errors..
mfcs42.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MainHook.obj
mfcs42.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in MainHook.obj; second definition ignored
Creating library ReleaseMinDependency/MSNdll.lib and object ReleaseMinDependency/MSNdll.exp
ReleaseMinDependency/MSNdll.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
please let me know what I have to do? Please...............(^_^)..........
Rahul Vaishnav
|
|
|
|
|
Rahul Vaishnav wrote: mfcs42
implies you're on the wrong discussion board (this one ain't for MFC). But here's a hint - you don't define DllMain for MFC projects - you override InitInstance of your CWinApp-derived class.
|
|
|
|
|
Hi Rashmi,
I don't know much about MMCSnapin...
but i have used below function for getting key press event in VC++(MFC,Dialog Based application)
May be it will help you...use Asci of F5 key VK_F5
BOOL CMyClass::PreTranslateMessage(MSG* pMsg)
{
if((pMsg->message==WM_KEYDOWN))
{
if(pMsg->wParam==13)
return FALSE;
if(pMsg->wParam==VK_ESCAPE || pMsg->wParam==VK_F5)
pMsg->wParam=NULL ;
}
return CDialog::PreTranslateMessage(pMsg);
}
Rahul Vaishnav
|
|
|
|
|
Hi Rahul..
Thanks for ur reply...
actualy m working in ATL....this post doesn't help me much..but yes...I got a clue from ur post that helped me much to proceed in a right direction,,
thanks again
|
|
|
|
|