Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mid Function

Status
Not open for further replies.

Shelyn

Programmer
May 15, 2003
18
MY
Hi All,

What is the Mid Function for Visual C++? Anyone has example for it?

Thanks in advance.
 
I know CString::Mid and this is the example I found from MSDN:
Example
The following example demonstrates the use of CStringT::Mid.

//typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;

CAtlString s( _T(&quot;abcdef&quot;) );
_ASSERT( s.Mid( 2, 3 ) == _T(&quot;cde&quot;) );


But I don't know how to use it. Can you write a simple code for me? Sorry, I am really not familiar with C. Thanks.
 
>But I don't know how to use it.

Ok. What do you wish to accomplish?

/Per
[sub]Nerdy signatures are as lame as the inconsistent stardates of STTNG.[/sub]
 

I just want to write the mid function to retrieve the character from the string. Like VB we just need to write
Mid(string, int, int), but for C++ I don't know how to apply the Mid function.
 
It is quite similar though Mid is a method to the CString class, not a standalone function.

Ie
VB:
someString = &quot;ABCDEFG&quot;
someOtherString= Mid(someString, 2, 3)
' someOtherString is now &quot;BCD&quot;

VC++
CString someString (&quot;ABCDEFG&quot;);
CString someOtherString = someString.Mid(2, 3)
// someOtherString is now &quot;BCD&quot;



/Per
[sub]Nerdy signatures are as lame as the inconsistent stardates of STTNG.[/sub]
 
Do I need to include any library? Coz when I wrote CString S, it gives me error that Undeclared identifier.
 
Well, CString is part of MFC, ie you shuold make an MFC application.

Use the Visual Studio's AppWizard to generate an MFC application for you.


/Per
[sub]Nerdy signatures are as lame as the inconsistent stardates of STTNG.[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top