[TriLUG] Email: HTML, replies, signatures, and signing
Steve Litt
slitt at troubleshooters.com
Thu Nov 27 13:33:19 EST 2008
On Thursday 27 November 2008 08:29:40 am Kevin Hunter wrote:
> At 9:16am -0400 on Wed, 26 Nov 2008, Michael Peters wrote:
> > Had to break out a little perl -le 'print scalar reverse q()' to keep my
> > head from hurtin'
>
> Heh. I had just deciphered the first line ("Just to contribute ..."),
> before I kicked myself:
>
> $ rev
> sdrawkcab enil yb depyt era segassem lla erehw
> stsop rorrim nwod edispU
> daerht siht fo noitaderged eht ot etubirtnoc ot tsuJ
Dohhhhhhh!
I didn't know about the rev command, and about a month ago I needed that
functionality and therefore wrote my own:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <assert.h>
int main(int argc, char *argv[]) {
int ss;
int stringlength = 0;
for (ss=1; ss < argc; ss++) {
// printf("Arg %d is %s\n", ss, argv[ss]);
stringlength += (strlen(argv[ss]) + 1);
}
char * src = malloc((stringlength+1) * sizeof(char));
assert (src != NULL);
char * dst = malloc((stringlength+1) * sizeof(char));
assert (dst != NULL);
*src='\0';
for (ss=1; ss < argc; ss++) {
strcat(src, argv[ss]);
strcat(src, " ");
}
src[strlen(src)-1] = '\0';
stringlength = strlen(src);
//printf("Src=>%s<=\n", src);
// Reverse into dst
for(ss=0; ss < stringlength; ss++) {
dst[stringlength-ss-1] = src[ss];
}
dst[stringlength]='\0';
//printf("Src=>%s<=\n", src);
printf("Dst=>%s<=\n", dst);
// Free malloc'ed stuff
free(dst);
free(src);
return 0;
}
More information about the TriLUG
mailing list