![]() |
| ||
| Reversive Array/Integer How can i write the coding for a reversive of a given integers. for example: char str[] = "012345"; Reverse( str ); printf( str ); then the output will be displayed as "543210" i need pointer as well to null-terminate string as a parameter and reverses this string. then, the string remains null terminated. void reverse(char *s) please help.this is very urgent. thanks. |
| ||
| Re: Reversive Array/Integer _strrev, _wcsrev, _mbsrev Reverse characters of a string. char *_strrev( char *string ); wchar_t *_wcsrev( wchar_t *string ); unsigned char *_mbsrev( unsigned char *string ); Routine Required Header Compatibility _strrev <string.h> Win 95, Win NT _wcsrev <string.h> or <wchar.h> Win 95, Win NT _mbsrev <mbstring.h> Win 95, Win NT Libraries LIBC.LIB Single thread static library, retail version LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version Return Value Each of these functions returns a pointer to the altered string. No return value is reserved to indicate an error. Parameter string Null-terminated string to reverse Remarks The _strrev function reverses the order of the characters in string. The terminating null character remains in place. _wcsrev and _mbsrev are wide-character and multibyte-character versions of _strrev. The arguments and return value of _wcsrev are wide-character strings; those of _mbsrev are multibyte-character strings. For _mbsrev, the order of bytes in each multibyte character in string is not changed. These three functions behave identically otherwise. Security Note These functions incur a potential threat brought about by a buffer overrun problem. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege. For more information, see Avoiding Buffer Overruns. Generic-Text Routine Mappings TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Definedif u want something else .. i will attach masteringstring.cpp ... |
| ||
| Re: Reversive Array/Integer Obfuscated for the sake of being too homework-sounding with no work presented. #include <stdio.h> |
| ||
| Re: Reversive Array/Integer Actually i was asking about integers, not string char. by given integers 012345, how can i actually reverse it? ..... |
| ||
| Re: Reversive Array/Integer Quote:
Quote:
char text[] = "012345"; /* "The quick brown fox"; */Did you consider converting an integer to a string, reversing it, and then converting it back to an integer? But no one is here to do your homework. What coding attempt have you posted? Or do you expect to post homework questions and simply get a correct answer, nicely formatted and commented? |
| ||
| Re: Reversive Array/Integer Quote:
see this example Summary An algorithm that reverses the order of elements in a sequence Synopsis #include <algorithm>Description The algorithm reverse() reverses the elements in a sequence so that the last element becomes the new first element, and the first element becomes the new last. For each non-negative integer i <= (finish - start)/2, reverse() applies iter_swap() to all pairs of iterators start + I, (finish - I) - 1. Complexity reverse() performs exactly (finish - start)/2 swaps. Example //if u need more explaination plz PM me..;) |
| All times are GMT -4. The time now is 5:12 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC