You could use getline, by keep in mind by default it will just grab 1 line of text, e.g. each input is delimited by the newline character. If you want to input multiple lines and preserve the formatting one option is just to use a loop and input char by char into a std::string. (Note: on windows in order to signal EOF you need to do <enter>ctrl^z<enter>)
Now being C++, you can drop all that C crap and do this using std::strings and the members of the string object to find and count your substring. This should get you going in the right direction:
Code:
#include <iostream>
#include <algorithm>
#include <string>
int main(void){
std::string input;
int charInput;
while((charInput=std::getchar())!=EOF)
input+=charInput;
std::cout <<"\nYou entered: \n\t"<<input;
std::transform(input.begin(),input.end(),input.begin(),::tolower);
std::cout <<"\nIn lower case: \n\t"<<input;
/* Use the functions provided by the std::string object to find your
substring and count your substring*/
std::cin.get();
return(0);
}
Now for a real C++ solution, you would drop the loop all together and just use the stream iterators to grab your input:
Code:
#include <iostream>
#include <algorithm>
#include <iterator>
#include <istream>
#include <string>
int main(void){
std::cin >> std::noskipws;
std::istream_iterator<char>start(std::cin);
std::istream_iterator<char>end;
std::string input(start,end);
std::cout<<"You entered:\n\n"<<input;
std::transform(input.begin(),input.end(),input.begin(),::tolower);
std::cout<<"\nLower case:\n\n"<<input;
return(0);
}