I need help in creating a function that will show  the first letter of the actual word. It is to be considered however that the words are randomly selected from a text file and usage of break, continue exit and global functions are not allowed. For example if the actual word is tiger and the word is jumbled as rgeti, (for instance), I want the new function to display "The first letter of the actual word is t ". This is my current code void scramble(char *p) {     int i = 0; int len=strlen(p)     while(i < len)     {         int c1 = (rand() % (len));         int c2 = (rand() % (len));         if(c1 != c2)         {             p[c1] = p[c1] ^ p[c2];             p[c2] = p[c1] ^ p[c2];             p[c1] = p[c1] ^ p[c2];             i++;         }     } }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter9: Completing The Basics
Section9.6: A Closer Look: Namespaces And Creating A Personal Library
Problem 6E
icon
Related questions
Question

I have created a C function that jumbles the word. (shown below). I need help in creating a function that will show  the first letter of the actual word. It is to be considered however that the words are randomly selected from a text file and usage of break, continue exit and global functions are not allowed.

For example if the actual word is tiger and the word is jumbled as rgeti, (for instance), I want the new function to display "The first letter of the actual word is t ".

This is my current code

void scramble(char *p)
{
    int i = 0;

int len=strlen(p)

    while(i < len)
    {
        int c1 = (rand() % (len));
        int c2 = (rand() % (len));

        if(c1 != c2)
        {
            p[c1] = p[c1] ^ p[c2];
            p[c2] = p[c1] ^ p[c2];
            p[c1] = p[c1] ^ p[c2];

            i++;
        }
    }
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning