Created
June 27, 2011 21:57
-
-
Save maluta/1049956 to your computer and use it in GitHub Desktop.
strfry example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* gcc -Wall -o strfry_example strfry_example.c */ | |
#define _GNU_SOURCE | |
#include <string.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
char *str = (char *) malloc(sizeof(char)*11); | |
char *ptr; | |
int i; | |
strcpy(str,"0123456789"); | |
printf("Original: %s\n\n",str); | |
for (i=0;i<10;i++) { | |
ptr = (char *) strfry(str); | |
printf("Randomized #%d: %s\n",i,ptr); | |
} | |
free(str); | |
return 0; | |
} |
A little note: sizeof(char)
is always 1 and you included string.h
twice.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tiago, thanks for the clear example of strfry()! Your gist was the first result when I was looking for example usage.