Write a function that accepts a pointer to a C-String as an argument and capitalizes the first character of each sentence in the string. For instance, if the string argument is "hello. my name is Joe. what is your name?" the function should manipulate the string so it contains "Hello. My name is Joe. What is your name?" Demonstrate the function in a program that asks the user to input a string and then passes it to the function. The modified string should be displayed on screen. Optional Exercise: Write an overloaded version of this function that accepts a string class object as its argument.
strPtr = strstr(sentence[i], ".");
setence[i] is just one character (like 'r'), ¿how do you expect to search in a character?
Can't suggest a correction as I had no idea what were you trying to do.
sentence[i] == '.' will compare array element i against '.'
strstr(sentence, ".") will find the first string "." in the sentence
strchr(sentence, ".") will also find the first char '.' in the sentence
Or do you mean this?
strPtr = strstr(&sentence[i], ".") search from the i'th element?
If so, you probably want to alter your loop so it works with strstr's return value, rather than just stepping the index by one. (It might be easier to use a while loop and a pointer, rather than the index, in this particular case?)
Andy
PS Why are you trying to capitalize a full stop/period?