|
name.substr(name.find_first_not_of(' '));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This would be easiest:
std::string name = "ABCD";
Now seriously: you should use string::find_first_not_of:
int pos = name.find_first_not_of(' ');
if (pos != std::string::npos)
{
name.erase(0, pos);
}
If you want to remove all spaces (not only at beginning), use this:
name.erase(std::remove(name.begin(), name.end(), ' '), name.end());
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Should you use CString you have the following methods: TrimLeft , TrimRight .
Best regards,
Alexandru Savescu
|
|
|
|
|
(with tremulous voice) Don't lead the guy apart from the one and true std::string ! Now seriously, these functions, though not directly available, can be easily written:
#ifndef TRIMTEMPLATES_H
#define TRIMTEMPLATES_H
#define VERSION_TRIMTEMPLATES 0x00010000
template<class String,class Ch>
inline String& trim_left(String& str,Ch ws)
{
typename String::size_type first_nonblank;
if ((first_nonblank=str.find_first_not_of(ws))!=String::npos)
return str.erase(0, first_nonblank);
else
return str;
}
template<class String>
inline String& trim_left(String& str)
{
return trim_left(str, ' ');
}
template<class String,class Ch>
inline String& trim_right(String& str,Ch ws)
{
typename String::size_type last_nonblank;
if((last_nonblank=str.find_last_not_of(ws))!= String::npos)
return str.erase(last_nonblank+1);
else
return str;
}
template<class String>
inline String& trim_right(String& str)
{
return trim_right(str, ' ');
}
template<class String,class Ch>
inline String& trim(String& str,Ch ws)
{
return trim_left(trim_right(str, ws),ws);
}
template<class String>
inline String& trim(String& str)
{
return trim_left(trim_right(str));
}
#elif VERSION_TRIMTEMPLATES!=0x00010000
#error You have included two LISTPORTS.H with different version numbers
#endif
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Don't lead the guy apart from the one and true std::string!
I never meant that! I like STL just as much as you do. I was just showing some MFC code
Best regards,
Alexandru Savescu
|
|
|
|
|
SHAME! SHAME! You should know better than to show MFC examples. People will get the mistaken impression its easier to use than the beloved STL.
|
|
|
|
|
Take it easy man!
I was not giving any MFC example, I was giving a CString example. CString is a very good class it can be argued that it is better than std::string (it uses reference counting remember!)
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexpro wrote:
it is better than std::string
SACRILEDGE!!
Alexpro wrote:
CString is a very good class
BLASPHEMY!!
Oh NO! STr o k e...
BTW CString is part of MFC. (Microsoft Foul Code). Everyone knows was developed as part of a feindish plot to undermine portablilty with Unix/Linux.
|
|
|
|
|
Hi everybody:
I want to display two modal dialogs, one first and the other when user clicks ok button on first dialog.
I try this:
CDialog1 dlg1;
m_pMainWnd = &dlg1;
int nResponse = dlg1.DoModal();
if (nResponse == IDOK)
{
CDialog2 dlg2;
m_pMainWnd = &dlg2;
nResponse = dlg2.DoModal();
...
}
in InitInstance function of my app but doesn't work (first dialog is ok but other dialog is showed and killed inmediately without user interaction)
Anybody can help me?
|
|
|
|
|
Remove lines assigning pointers to m_pMainWnd.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Is it that? What's the reason of this behavior?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
See my reply to your reply to OP
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Thanxs a lot. It is running well now.
|
|
|
|
|
The code seems OK. Try switching the order of appearance of the dialogs (just for the purpose of debugging), maybe the CDialog2 one is not showing for reasons not having to do with your question.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you Tomasz.
Gracias Joaquin.
|
|
|
|
|
The secret lies in CWnd::OnNcDestroy. The method compares this with m_pMainWnd and posts quit message if so.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Man, that's funny! Thanx a lot for the piece of info.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am using MIME to send an HTML file and associated JPG file to a clients who are using Outlook Express. I am using an associated ID to refer to the image inside the HTML file. I'm also using
http-equiv=3DContent-Type.
I am experiencing two problems. One client, running Windows 98, can see the image, but no table-related text, the other clients running 2000 can see both text and image. Neither, however, can print the image directly from Outlook. Only the much hated square with the IMG alt tag and red cross.
Has any one else experienced this problem? And more importantly does anyone have any idea how to fix it?
|
|
|
|
|
hello,
how do i check if i am connected to the internet ? so far i've found 2
ways to do that.
- InternetAttemptConnection
but this works only for modem conncections
- InternetCheckConnection
works for nearly all types of connections, but not always
is there any 100% version (proxy, firewall .... )
Thanks
here is my solution:
// worker thread
BOOL WINAPI IsConnected()
{
do {
#ifdef ADSL
g_IsConnected=InternetCheckConnection ("http://www.google.com",
FLAG_ICC_FORCE_CONNECTION ,0);
#elseif
if(InternetAttemptConnect(0) == ERROR_SUCCESS) g_IsConnected = true;
else g_IsConnected = false;
#endif
Sleep(2500);
} while(1);
}
|
|
|
|
|
when does InternetCheckConnection not work?
I'm interested because I'm using it now and I havn't found any problems... but then again I haven't released my software yet.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
FROM MSDN
There are some other ways to try to determine if you currently have a connection to a particular network resource. The IsDestinationReachable() function can be used to find out if there is a current connection to an address. However, he IsDestinationReachable() function is only concerned with whether the IP address is reachable from your computer. It does not work through HTTP proxies or firewalls that restrict ICMP ping packets.
--> thats the same for InternetCheckConnection
|
|
|
|
|
bool isConnectedToInternet()
{
bool bConnected = false;
DWORD dwFlags;
if (::InternetGetConnectedState (&dwFlags, 0)) {
if ((dwFlags & INTERNET_CONNECTION_LAN) ||
(dwFlags & INTERNET_CONNECTION_MODEM) ||
(dwFlags & INTERNET_CONNECTION_PROXY)) {
bConnected = true;
}
}
return (bConnected);
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I am implementing a application in which i want to have a graph just like the task manager. I am not getting the idea of how to exactly implement the animated graph. ( I tried using memory bitmaps but the logic is clicking )
Help me
Thanks
Vikash
mail to:vikashdubey@hotmail.com
|
|
|
|
|
Vikash Dubey wrote:
I tried using memory bitmaps but the logic is clicking
Can you elaborate on the 'clicking' part?
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
sorry not clicking(means not working) can you help on the moving graph logic.
Thanks
Vikash
|
|
|
|