I'm trying to only input the strings that start with A and if other letters is used giving a error message. I've tired this:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
char str[30];
if(str[0] == "A"){
cin.get(str, 30);
}else{
cout<<"Any name other than starting from A isn't supported."<<endl;
cout<<str<<endl;
return 0;
}
}
I get this error: trialz.cpp: In function 'int main()': trialz.cpp:7:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 7 | if(str[0] == "A"){ | ^~~ I'm a beginner and your help will be much appreciated!!