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]
Your email is never published nor shared. Required fields are marked *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
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]