Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

strrev(3pub) [debian man page]

STRREV(3pub)						       C Programmer's Manual						      STRREV(3pub)

NAME
strrev - reverse a string in place SYNOPSIS
#include <publib.h> char *strrev(char *str); DESCRIPTION
strrev reverses the argument string in place, i.e., it swaps the ith character from the beginning with the ith character from the end. RETURN VALUE
strrev returns its argument. EXAMPLE
Reversing "dlrow, elloh" would be done like the following. char str[] = "dlrow, elloh"; puts(strrev(str)); This would output "hello, world". Note that using the string literal as the argument would be an error, since it is not allowable to mod- ify string literals. BUGS
Does not automatically detect palindromes, nor automatically return without doing anything. SEE ALSO
publib(3), memrev(3) AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi) Publib C Programmer's Manual STRREV(3pub)

Check Out this Related Man Page

MEMSHUFFLE(3pub)					       C Programmer's Manual						  MEMSHUFFLE(3pub)

NAME
memshuffle - make an array be in random order SYNOPSIS
#include <publib.h> void *memshuffle(void *block, size_t elsize, size_t elnum); DESCRIPTION
memshuffle will move around the elements of an array in a random fashion. It uses the standard library function rand(3) to get the pseudo- random numbers it needs. The caller must set a suitable seed with srand(3). RETURN VALUE
memshuffle returns its first argument. EXAMPLE
To shuffle an integer array one might do the following. int array[4] = { 1, 2, 3, 4 }; memshuffle(array, sizeof(array[0]), 4); BUGS
On many systems rand(3) is not of very good quality. However, it is the only random number generator that can be assumed to exist. Making it possible for the caller to provide an alternate source of random numbers (e.g., via a function pointer) is perhaps too more trouble than its worth. A better way would be for everyone to fix their rand's. SEE ALSO
publib(3), memrev(3), rand(3), srand(3) AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi) Publib C Programmer's Manual MEMSHUFFLE(3pub)
Man Page

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

string revering fails

Consider the following code #!\bib\bash echo -n "Enter string : " read str l=`expr length "$str"` while do echo -e `echo $str | cut -c"$l"`"\c" l=`expr "$l" - 1` done echo the above code works perfect for string with no space in between. but fails when there is a... (2 Replies)
Discussion started by: lipun4u
2 Replies

2. Programming

malloc vs realloc

Why when using realloc, john is reversed 3 times but not the other 2 names ? But if I use malloc, then the 3 names are reversed correctly ? (but then there is a memory leak) How can I reverse all 3 names without a memory leak ? char *BUFFER = NULL; char *STRREVERSE(const char *STRING) {... (5 Replies)
Discussion started by: cyler
5 Replies

3. Programming

String reverse

Hi all, I jus wanna print string b after reversing it. but the out put is blank. My code snippet is below. :wall: int main() { char * a, * b; b = new char; a = new char; int len, le; le = 0; cout<< " enter your string \n"; cin>> a; len = strlen(a); for(int i =... (8 Replies)
Discussion started by: vineetjoshi
8 Replies

4. Programming

segfault in pointer to string program

hello all, my question is not about How code can be rewritten, i just wanna know even though i am not using read only memory of C (i have declared str) why this function gives me segfault :wall:and the other code executes comfortably though both code uses same pointer arithmetic. ... (4 Replies)
Discussion started by: zius_oram
4 Replies

5. Programming

String pointer does not work

Hello, I am trying to reverse complement one string and reverse another (NO complement!), both with pointer. My code compiled without error, but did not do the job I wanted. #include <stdio.h> #include <stdlib.h> #include <zlib.h> #include "kseq.h" // STEP 1: declare the type of file... (5 Replies)
Discussion started by: yifangt
5 Replies

6. Shell Programming and Scripting

Need to Speed up shell script

Hello, I am basic level shell script developer. I have developed the following script. The shell script basically tracking various files containing certain strings. I am finding options to make the script run more faster. Any help/suggestion would be appreciated :) #! /bin/bash # Greps for... (6 Replies)
Discussion started by: Bhanuprasad
6 Replies