Help Me! 6:12: error: comparison between pointer and integer ('char' and 'const char *')

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stoney L
    New Member
    • May 2022
    • 11

    Help Me! 6:12: error: comparison between pointer and integer ('char' and 'const char *')

    Well, dudes, I'm back for another question:What deal is with this?
    The error is:
    tempCodeRunnerF ile.cpp:6:12: error: comparison between pointer and integer ('char' and 'const char *')
    So next, there is my code:
    #include <iostream>
    using namespace std;
    int main() {
    char a;
    int ascii,suma,sumb ,sumc;
    while(a!="?"){
    cin>>a;
    a=ascii;
    if (ascii>60&&asci i<123||ascii>64 &&ascii<91){
    suma=suma+1;
    }
    if (ascii>47&&asci i<58) {
    sumb=sumb+1;
    }
    if (ascii>31&&asci i<48) {
    sumc=sumc+1;
    }
    if (ascii==63) {
    break;
    }
    }
    cout<<sumb<<end l<<suma<<endl<< sumc<<endl;
    return 0;
    }
    (Tips:I'm using Visual Studio Code.)
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    Code:
    while ( a != "?" ){
    Double quotes are used for string literal. In the first iteration, a isn't initialized to a value and used for comparison in an entry-controlled loop.

    Code:
    a = ascii;
    Why would you update a after the input?

    ascii is never initialized.

    Increment to suma, sumb and sumc are done without any initial value.

    Comment

    Working...