I have seen many ways to REMOVE punctuation marks in an array, but how would one go about it when implementing it in a function? This is what I have so far
1 2 3 4 5 6 7 8 9 10 11 12
int countAllPunctuation(const string array[], int n)
{
int punctuation = 0;
for (int i = 1; i < n; i++)
{
punctuation = i;
}
return punctuation;
}
#include <iostream>
using std::cout;
#include <locale>
using std::ispunct;
#include <string>
using std::string;
int main()
{
int numPunct = 0;
string sentence = "Howard, lol! You ate - MY DUCK!";
for (auto it = sentence.begin(); it!=sentence.end(); ++it)
{
if (ispunct(*it))
{
++numPunct;
}
}
cout << numPunct << " punctuation marks found";
return 0;
}
Here would be an example using the same with an array: