Home > Back-end >  This program run there is a problem, don't know where the problem is, for a great god solve
This program run there is a problem, don't know where the problem is, for a great god solve

Time:09-19

# include
# include
using namespace std;
Int main () {
Char s [80], a;
int i;
Cin. Getline (s, 80);
Cin> a;
for(i=0; S [I]!='\ 0'; I++) {
If cout< (s [I]==a); & lt;" The characters in a string for the first time in the subscript is: "& lt; }
If (I - 1==strlen (s)) cout<1 & lt; return 0;
}

CodePudding user response:

Break the location of the wrong, it should belong to the if statement inside, add a bracket on the

 # include 
# include
using namespace std;
Int main () {
Char s [80], a;
int i;
Cin. Getline (s, 80);

Cin & gt;> a;
for (i=0; S [I]!='\ 0'; I++) {
If (s==a) [I] {
Cout & lt; <"The character in the string for the first time in the subscript is:" & lt; break;
}
}
If (I - 1==strlen (s)) cout & lt; <1 & lt; return 0;
}
  • Related