I have this one hard questions that I can't find the answer. Anyone of you know how to do this? Question 2 (30 marks) a) Create a new text file and name it as TEXT1.txt. Write the following content into this text file: Always attend your lecture and tutorial classes Using the C programming language i. Create a function named vowelwords(). This function reads the content of TEXT1.txt file and prints out on screen the words that do not start with either an uppercase or lowercase vowel (i.e, with ‘a’,’e’,’i’,’o’,’u’). For example, if TEXT1.txt file contains: Ooi Chee Pun! Always attend your lecture and tutorial classes then Chee Pun! your lecture tutorial classes will be printed on screen. Note: You should determine the appropriate arrays and variables to be used. ii. Write a main() function, which calls the created vowelwords() function. b) Modify the vowelwords()function in part (a) to write the words that do not start with either an uppercase or lowercase vowel into a new text file called TEXT2.txt.
Looks easy enough. 30 marks? No wonder people think exams are getting easier. Anyway, do you understand the question? Where are you stuck? What have you tried? You'll probably need a function to read words from the input file. If you haven't got one, you can read one character at a time with fgetc(). For myself I would probably create a state machine that reads one character at a time into a buffer, checking for end of word and changing state accordingly, then on the state transition from word to not-a-word I would call a function which inspects the word that's been read in to determine whether or not it should be printed, then either print it or not depending on the result. (b) is then a simple case of modifying the above function, probably by adding an else clause, and I'd probably use fputs() to write the word to the file, or maybe fprintf() so I could easily add formatting (like a space, newlines, etc).