String Problem
-
The idea was given to you here[^]. Why don't you try to devise a logic? If you want to strip down to the first directory from the root, then why not use CString::Find() instead of CString::ReverseFind() ?!
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
I am useing this.
CString DirPath;
CString FullPath = _T("C:\\abc\\cd\\as.txt");int nPos = FullPath.Find( \_T('\\\\') ); if( nPos >= 0 ) { DirPath = FullPath.Mid( 0, nPos); } AfxMessageBox(DirPath);
Then i am geting out put C: But i need to C:\abc. Plz tell me what i use. Thanks in advance
-
I am useing this.
CString DirPath;
CString FullPath = _T("C:\\abc\\cd\\as.txt");int nPos = FullPath.Find( \_T('\\\\') ); if( nPos >= 0 ) { DirPath = FullPath.Mid( 0, nPos); } AfxMessageBox(DirPath);
Then i am geting out put C: But i need to C:\abc. Plz tell me what i use. Thanks in advance
rdop wrote:
Then i am geting out put C: But i need to C:\abc. Plz tell me what i use.
I'm terribly sorry, but this is logic on kindergarten level. If you sincerely do not understand, or you're too lazy to figure out why you got that result and what to do to fix it, I suggest you find another profession. Best of luck. :rose: -- Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
rdop wrote:
Then i am geting out put C: But i need to C:\abc. Plz tell me what i use.
I'm terribly sorry, but this is logic on kindergarten level. If you sincerely do not understand, or you're too lazy to figure out why you got that result and what to do to fix it, I suggest you find another profession. Best of luck. :rose: -- Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
You're wasting your time, Rajesh. He just wants a quick fix, he's too lazy to attempt to understand what he's doing or what he should be doing.
Michael Schubert wrote:
He just wants a quick fix
Ah, I hadn't realized it was urgnz. :)
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
-
I am useing this.
CString DirPath;
CString FullPath = _T("C:\\abc\\cd\\as.txt");int nPos = FullPath.Find( \_T('\\\\') ); if( nPos >= 0 ) { DirPath = FullPath.Mid( 0, nPos); } AfxMessageBox(DirPath);
Then i am geting out put C: But i need to C:\abc. Plz tell me what i use. Thanks in advance
rdop wrote:
int nPos = FullPath.Find( _T('\\') );
Why do you use
Find
, instead of (suggested)ReverseFind
? :) [added] BTW since now the request is urgent, please feel free to visit www.cpallini.freeproductz.com to get theJITS
(J
ustI
nT
imeS
olution). :-D [/added]If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Friday, October 3, 2008 7:45 AM
-
rdop wrote:
int nPos = FullPath.Find( _T('\\') );
Why do you use
Find
, instead of (suggested)ReverseFind
? :) [added] BTW since now the request is urgent, please feel free to visit www.cpallini.freeproductz.com to get theJITS
(J
ustI
nT
imeS
olution). :-D [/added]If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Friday, October 3, 2008 7:45 AM
I hope that you've read the entire thread. :~ BTW, the query has now become an Urgnz one. :((
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
-
rdop wrote:
int nPos = FullPath.Find( _T('\\') );
Why do you use
Find
, instead of (suggested)ReverseFind
? :) [added] BTW since now the request is urgent, please feel free to visit www.cpallini.freeproductz.com to get theJITS
(J
ustI
nT
imeS
olution). :-D [/added]If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Friday, October 3, 2008 7:45 AM
-
Its urgentzzzz plzzzz May be you want to give him link to your magic site.. :D
Regards, Sandip.
:omg: I forgot about :omg: Fixed! :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Its urgentzzzz plzzzz May be you want to give him link to your magic site.. :D
Regards, Sandip.
SandipG :) wrote:
May be you want to give him link to your magic site
No no sir, he mustz learnz himself.
-
Ok i got your point what i will do.I will try to move other field.Can you give me solution of that problem. Thanks in advance
Yes, for instance [^]. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
SandipG :) wrote:
May be you want to give him link to your magic site
No no sir, he mustz learnz himself.
-
Michael Schubert wrote:
No no sir, he mustz learnz himself.
Yes the magic site will help him to learn :D You don't know about the magic site, do you?
Regards, Sandip.
Never mind - and yes, I do know Carlo's magic site.
-
Never mind - and yes, I do know Carlo's magic site.
-
Never mind - and yes, I do know Carlo's magic site.
And THHB stands for: Thread Hijacking Happy Brigade. :)
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
-
And THHB stands for: Thread Hijacking Happy Brigade. :)
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
Thanks for enlightening me! ;)
-
Thanks for enlightening me! ;)
Michael Schubert wrote:
Thanks for enlightening me!
We aim to please. :) BTW, this is just another crime of the THHB. Look how much it's been hijacked. :-\
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
-
Michael Schubert wrote:
Thanks for enlightening me!
We aim to please. :) BTW, this is just another crime of the THHB. Look how much it's been hijacked. :-\
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
Rajesh R Subramanian wrote:
Look how much it's been hijacked.
Combined efforts really pay off. :)
-
Michael Schubert wrote:
Thanks for enlightening me!
We aim to please. :) BTW, this is just another crime of the THHB. Look how much it's been hijacked. :-\
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
Hey! You and Sandip, evil guyz, are making be bouncing from this thread to my memberpage... :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
rdop wrote:
CString array[10]
Which will hold strings like:
array[0] = "This is string 1";
array[1] = "This is string 2";
array[2] = "This is string 3";
...
array[9] = "This is string 10";Is that really what you intended?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Hi All I have a problem to cut the string.How can i cut this string last file name. Old String
C:\abc\cd\as.txt
And i want to show New String
C:\abc\cd
Plz help me
Use
PathRemoveFileSpec()
."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch