fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cctype>
  4. #include <string>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. vector<string>words;
  10.  
  11. //stores words to vector words
  12. void storeWords()
  13. {
  14. cout << "Input 8 words: " << endl;
  15. string s = " ";
  16. for(int i=0; i<=7; i++)
  17. {
  18. cin >> s;
  19. words.push_back(s);
  20. }
  21. }
  22. //prints our words
  23. void printWords()
  24. {
  25. cout << "\n Words stored in vector: " << endl;
  26. for (const string s : words)
  27. cout << s << endl;
  28. }
  29.  
  30. //replaces chars of the first word with a '?' sign
  31. void replace1(vector<string>&v)
  32. {
  33. cout << "\nReplaced characters of the first word " << words[0] << " with '?'" << endl;
  34. for (char c : words[0])
  35. cout << "?";
  36. }
  37.  
  38. void replace2(vector<string>&v)
  39. {
  40. for (char& c : words[7])
  41. {
  42. if(islower(c))
  43. c = toupper(c);
  44. }
  45. cout << endl;
  46. cout << words[7]<<endl;
  47. }
  48.  
  49.  
  50. int main()
  51. {
  52. storeWords();
  53. printWords();
  54. replace1(words);
  55. replace2(words);
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0s 3476KB
stdin
Hello my name is bob and i like
stdout
Input 8 words: 

 Words stored in vector: 
Hello
my
name
is
bob
and
i
like

Replaced characters of the first word Hello with '?'
?????
LIKE