Hey, I am a beginner and have a q. i have a task to leave only first capital letter in each sentence from given uppercase text in file. My code works, but since text in file is in separate lines, <char_array[0]=toupper(char_array[0]);> capitalises firs letter of each line. How can i avoid capitalising first letter of second line?cuz its not the beginning of the sentence? my text:
AMBITIONI DEDISSE SCRIPSISSE IUDICARETUR.ARAS
MATTIS IUDICIUM PURUS SIT AMET FERMENTUM.AONEC
SED ODIO OPERAE, EU VULPUTATE FELIS RHONCUS.
Your code is too complex and won't work if there are any spaces after the period, exclamation mark or question mark.
You should deal with character by character, not store them in arrays.
Scan your input, keeping a "state" for capital letters which is set to true whenever the character encountered is one of .?! and set to false after writing any alphabetic letter. As a character is read, put it in upper or lower case according to your current "state" of capitalisation.
And just get the sentence from the capture group. You can then make the first one uppercase and all others lowercase. Then you can recursively do this for all the sentences