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

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

NAME
stracat - concatenate many strings into an allocated memory block SYNOPSIS
#include <publib.h> char *stracat(const char *s, ...); DESCRIPTION
stracat will allocate a block of memory with malloc and concatenate all arguments strings into this block. The user is supposed to free the returned block. The end of the argument list is signalled by a null pointer. RETURN VALUE
stracat returns a pointer to the allocated block, or NULL if it could not be allocated. EXAMPLE
To concatenate "hello, " and "world", one might say the following. p = stracat("hello, ", "world", (char *)NULL); if (p != NULL) puts(p); Please note that it is necessary to case NULL as in the example above, since there is no information about the type of the argument available in the prototype, and since an unadorned NULL might not be of the correct type. (See any good C reference book or the comp.lang.c FAQ for more information.) SEE ALSO
publib(3), strcat(3) AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi) Publib C Programmer's Manual STRACAT(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