string

I need help with this code,,,
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

string reverseString(string i)
{
string r = 0;
string rev = 0;
}
bool isVowel(char c)
{

}

bool isPunctuationMark(char c)
{

}

int main ()
{
cout << "Enter a string: \n";
string string;
getline(cin, string);
cout << "You entered: " << string << endl;

cout << " " << endl;

// your program is to read in a string (including spaces);

// cout << digits, letters (uppercase and lowercase), spaces, vowels, punctuation, others

// show a reverse string
//(dont overwrite original string)

return 0;
}
please help thanks
***
Write a program that requests the user to enter a string that includes a combination of letters
(uppercase or lower), digits, spaces, punctuation marks and/or any other keyboard symbols.
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/203952/
That link is broken.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
std::string reverse(const std::string &s)
{
    return std::string(s.crbegin(), s.crend());
}

bool isVowel(char c)
{
    const std::string vowels = "aAeEiIoOuU";
    return vowels.find(c) != std::string::npos;
}

bool isPunct(char c)
{
    const std::string punct = "+=%₩<>!@#~/^&*()-\'\":;,\?`_\\|{}[]$€£¥";
    return punct.find(c) != std::string::npos;
}
Last edited on
1
2
3
4
5
6
7
8
9
std::string reverse( const std::string &s ) { return { s.rbegin(), s.rend() } ; }

bool is_vowel( char c )
{
    static const std::string vowels = "aAeEiIoOuU" ;
    return vowels.find(c) != std::string::npos ;
}

bool is_punct( char c ) { unsigned char uc = c ; return std::ispunct(uc) ; }
@JLBorges

What if the OP is not allowed to use the <cctype> library? If the OP can use other libraries, then std::reverse() could be used.

P.S. How does line 1 work? Also, what does keyword static do and why do you use it?
Last edited on
thanks guys!!!!
Topic archived. No new replies allowed.