1 Replies - 326 Views - Last Post: 07 July 2008 - 02:21 AM

#1 GeryGoose   User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 197
  • Joined: 24-February 05

Scramble Letters and Numbers in a String

Posted 05 April 2005 - 02:00 PM

Description: This is very simple to use. You simply put this above where ever you want to use it. And to call it simply type scrambleString(your_string_name); This really serves no purpose unless it is for a project. Make sure include everything listed.This function takes a string and scrambles all of the characters in it.
#include <iostream>
#include <string.h>
#include <time.h>
using namespace std;

int scrambleString(char* str)
{
     int x = strlen(str);
     srand(time(NULL));
     for(int y = x; y >=0; y--)
     {
          swap(str[rand()%x],str[y-1]);
     }
     return 0;
}


Is This A Good Question/Topic? 0
  • +

Replies To: Scramble Letters and Numbers in a String

#2 chuck981996   User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 119
  • Joined: 03-July 08

Re: Scramble Letters and Numbers in a String

Posted 07 July 2008 - 02:21 AM

Doesn't work for me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1