Need help with putting quotation marks around a value.

This program counts occurrences of a character upper or lower in a string. Need the char (toupper(c)) to have quotes around it. heres my code.

#include <stdio.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
string s;

char c;

int c1 = 0;


cout << "Enter string: ";
cin >> s;

cout << "Enter character: ";
cin >> c;

for(int i = 0; i< s.size(); i++){
if(s[i]==c)
c1++;

if(s[i]==toupper(c))
c1++;
}

cout << endl;

cout << char (toupper(c)) <<" appears " << c1 << " time(s)";

return 0;
}
Last edited on
To add quotes within a string, you need to escape them in your code.
A " is escaped by using a backslash, \" .

cout << "\"" << char (toupper(c)) <<"\" appears " << c1 << " time(s)";
Topic archived. No new replies allowed.