Question: PROGRAM MUST BE IN C. COMPILER IS XCODE. Declare all prototypes, variables, comments, etc. Program English to Pig Latin My code is not compiling correctly
PROGRAM MUST BE IN C. COMPILER IS XCODE.
Declare all prototypes, variables, comments, etc.
Program English to Pig Latin
My code is not compiling correctly and no matter what I change it is NOT working. Please help.
Introduction
As most of you know, pig Latin is a language game played with English words. It is based on discriminating between vowels and consonants within the word. (Note that a vowel is any of the characters a, e, i, o, or u. A consonant is any non-vowel character.)
Any English word can be converted to its pig Latin equivalent by using the following algorithm:
1) Starting from the first character of the word, locate the position of the first vowel.
2) If there is a consonant (or a string of consonants) to the left of that position, do the following:
a) Extract the leading consonant(s) from the word. What remains will begin with a vowel by definition. Lets call that the residual string.
b) Append an ay to the end of the consonant string creating a suffix string.
c) Append the suffix string to the end of the residual string using a hyphen.
3) If the first letter of the word is a vowel, then append -way to the end of the word.
For example, lets say we want to convert the word cabin to pig Latin. Following the above steps, we do the following:
1) We locate the position of the first vowel. This is the a that occurs at index 1 in the string (i.e., it is the second letter in the string).
2) Since there is a leading consonant in this case, c, it is removed from the word creating the residual string = abin.
a) We take the consonant, c, append an ay to it, creating the suffix string = cay.
b) We append that to the end of the residual string using a hyphen.
3) The final result is abin-cay.
Similarly, lets say that we want to convert the word apple to pig Latin. Following the above steps, we do the following:
1) Locate the position of the first vowel. Since it is at index position 0, it is the first character in the string.
2) Since the first character of the word is a vowel, there are no leading consonants to peel off. Therefore, we simply append a -way to the end.
3) The final result is apple-way.
Assignment
For this assignment, you will write a function that converts a single English word to its pig Latin equivalent. That function should have a header as follows:
char * convertToPigLatin (char * engStr, char * pLatinStr)
Youll note that it takes two char * as input and returns a char *, as expected. The two inputs are pointers to the English string and the converted Pig Latin string respectively. The return value should be a pointer to the Pig Latin string. That return value can then be assigned to a variable and used to print out the converted string, either to the console or to a file.
Your program should then perform the following steps:
1) Open a file for input called pigLatinIn.txt, which will be provided to you. This file will consist of one English word per line.
2) Open a file for output called pigLatinOut.txt.
3) Your program will then read the input file, use the convertToPigLatin() function to determine the pig Latin equivalent to the word, then write the following to the output file:
English Word Pig Latin Word
------------ --------------
cabin abin-cay
apple apple-way
4) Print out the results in all lower case.
BELOW IS THE "pigLatinIn.txt" text
go placidly amid the noise and haste and remember what peace there may be in silence as far as possible without surrender be on good terms with all persons speak your truth quietly and clearly and listen to others even the dull and the ignorant they too have their story if you compare yourself with others you may become vain or bitter for always there will be greater and lesser persons than yourself enjoy your achievements as well as your plans be yourself especially do not feign affection beyond a wholesome discipline be gentle with yourself you are a child of the universe no less than the trees and the stars you have a right to be here and whether or not it is clear to you no doubt the universe is unfolding as it should be cheerful strive to be happy
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
