Skip to content

Instantly share code, notes, and snippets.

@maluta
Created June 27, 2011 21:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maluta/1049956 to your computer and use it in GitHub Desktop.
Save maluta/1049956 to your computer and use it in GitHub Desktop.
strfry example
/* 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;
}
@hgrubbs
Copy link

hgrubbs commented Aug 26, 2015

Tiago, thanks for the clear example of strfry()! Your gist was the first result when I was looking for example usage.

@darealshinji
Copy link

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