Home > Back-end >  The problem is in the initial for statement read "$$$$$" stop reads want ask bosses
The problem is in the initial for statement read "$$$$$" stop reads want ask bosses

Time:09-22

# include
# define number 3
Int main (void)
{int I;
Char s [number] [128];
for(i=0; i{printf (" s [% d] : ", I);
The scanf (" % s ", s [I]);
If (' s [I] [128] '==' $$$$$')
break;
}
for(i=0; i{printf (" s [% d]=\ "% s \ " n ", I, s [I]);
}
return 0;
}

CodePudding user response:

Use STRCMP to compare strings, do not use the==

CodePudding user response:

The comparison of string class assignment has its own exclusive function, can't use the set of integers, encapsulates the c + + to use, look at the string. In h strcpy, STRCMP, strcat these functions

CodePudding user response:

If (STRCMP (s [I] [128], "$$$$$")==0)//want to use double quotation marks here

CodePudding user response:

 # include 
#include

# define number 3

Int main (void)
{
int i;
Char s [number] [128];
for(i=0; i{printf (" s [% d] : ", I);
The scanf (" % s ", s [I]);
//if (' s [I] [128] '==' $$$$$')
If (STRCMP (s [I], "$$$$$")==0)
break;
}
for(i=0; i{
Printf (" s [% d]=\ "% s \ " n ", I, s [I]);
}
return 0;
}

For your reference ~

CodePudding user response:

Single-byte can't compare with string

CodePudding user response:

Thank you resolved when the answer thank you
references 4 building self-confidence boy reply:
 # include 
#include

# define number 3

Int main (void)
{
int i;
Char s [number] [128];
for(i=0; i{printf (" s [% d] : ", I);
The scanf (" % s ", s [I]);
//if (' s [I] [128] '==' $$$$$')
If (STRCMP (s [I], "$$$$$")==0)
break;
}
for(i=0; i{
Printf (" s [% d]=\ "% s \ " n ", I, s [I]);
}
return 0;
}

For reference ~


references 4 building self-confidence boy reply:
 # include 
#include

# define number 3

Int main (void)
{
int i;
Char s [number] [128];
for(i=0; i{printf (" s [% d] : ", I);
The scanf (" % s ", s [I]);
//if (' s [I] [128] '==' $$$$$')
If (STRCMP (s [I], "$$$$$")==0)
break;
}
for(i=0; i{
Printf (" s [% d]=\ "% s \ " n ", I, s [I]);
}
return 0;
}

For reference ~
  • Related