Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

idk why is it giving me an [Error] expected primary-expression before 'char'

#include <iostream>
using namespace std;


int main() {
    int input;
    cout<<"type s";
    (input == char*s) cout<<"good";
}

i typed this simple code when you press s it will say good but it wont work and i get this

[Error] expected primary-expression before 'char'

when i try this code it gives me [Error] expected primary-expression before ‘char’. idk why this is happening and i know this probably looks like a mess to experienced people

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The code you wrote does not make any sense. I don’t know where you are getting your information from but you need to learn C++ from a good source. You cannot learn C++ by trial and error.

Something like this code will do something like what you want

#include <iostream>
using namespace std;

int main() {
    cout<<"type s\n";
    char input;
    cin >> input;
    if (input == 's') cout<<"good\n";
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading