#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    File and String Manipulation


    Would Really Appreciate any help!!!!!!!!
    I am a newbee in programming and finding this to be a very tricky question.

    Need help to write a C program that will create scrambled words by circularly rotating the middle characters of each word by 1 character.
    Place the scrambled words, 1 per line in an output file.

    Example:
    sunday becomes sndauy

    The Input File format is such that the first line contains a number indicating the number of words in the file, followed by one line for every word to be scrambled (no spaces in any of the words).

    Sample input file:
    3
    hut
    create
    ready
    people

    Sample output file:
    hut
    ceatre
    radey
    poplee
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    How do you get the input and output file names?
    I'd use stdin and stdout with command line redirection, as in
    $ myprogram < wordlist.txt > scrambled.txt

    You'll assuredly respond that that is illegal. Even so, it might be a good start.

    Can you write a program that copies input to output?
    Opens a file for reading or for writing?

    Why is people scrambled in your output example?
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    Hi, thanks for responding..

    I would create the text files, one for input and one for output.
    The program has to read the files from The input text file (e.g. input.txt) and write the scrambled words to output file (e.g output.txt)

    The scramble words are created by circularly rotating the middle characters of each word by 1 character.
    That is how all the words are shown including "people"in the previous example.

    I have tried coding and my program is all over in bits and pieces .

    Would really appreciate your response.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    Please post your effort so we can review. Follow the link at my signature for advice about how to post code. Thanks.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo