Results 1 to 4 of 4

Thread: Random Function to Concatenate 2 strings

  1. #1
    Join Date
    Aug 2009
    Posts
    36

    Random Function to Concatenate 2 strings

    I have a problem for the creation of my program, here's what I'd like to do:

    cVar1 char = 0;
    cVar2 char = 0;
    cVar3 char = 0;
    cVar4 char = 0;

    The name comes from a scanf which wants and now it does this:

    cVar1 char = a;
    char cVar2 = b;
    cVar3 char = c;
    char cVar4 = d;

    how can they repeated on both lines at random?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Random Function to Concatenate 2 strings

    What you want to do: the user enters two strings, and you mix all the characters and redistributed at random from the 2 channels, right? If so, I advise you to consider the function ran () "and the modulo operator (%). Basically ran function generates a random number and the% operator can transform into a number small enough to serve as an index of your chain.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Random Function to Concatenate 2 strings

    To concatenate a string, remember that strings are basically arrays of characters.If you have string1 = "dot1" and string2 = "dot2". To concatenate 2 strings you can use simbol +. So, string1 + string2 will be one string.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Random Function to Concatenate 2 strings

    The cVar1 = a, and% s is not set, It should be an array (cVar1 [100] for example). Then you must use the ran and the module. Personally I'd make a 2D array. You put your sentences in cvar [0], cvar [1], cvar [2], cvar [3] and you display them like that cvar [rand ()% 4].

Similar Threads

  1. Replies: 4
    Last Post: 13-01-2012, 05:07 PM
  2. Strings function in MySQL
    By Dino M in forum Software Development
    Replies: 6
    Last Post: 09-12-2010, 04:01 AM
  3. StackOverflow Error and Random function
    By Trini Alvarado in forum Software Development
    Replies: 5
    Last Post: 11-03-2010, 01:49 PM
  4. Function for two random numbers
    By Zool in forum Software Development
    Replies: 3
    Last Post: 03-12-2009, 12:39 PM
  5. Create a function for comparing character strings
    By Zool in forum Software Development
    Replies: 3
    Last Post: 16-10-2009, 01:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,052,483.18251 seconds with 17 queries