How to reverse a string (using library function)?

 

Reversing a string is one of the first programs we write when we learn about loops. Anyway you don’t have to write the usual loop again to reverse a string. You can use _tcsrev ( _strrev ) function to reverse a character buffer. See the sample below

[sourcecode language='cpp']
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR buff[] = _T( “Hello World!”);
_tcsrev( buff );
_tcprintf( buff );
return 0;
}
[/sourcecode]

 
This entry was posted in Uncategorized. Bookmark the permalink.