[Solved] The array index doesnt show the character [closed]


In your conditional statement, you’re assigning space to s[ i ] (operator =). You want to compare them (operator ==).

Try

if (s[ i ] == ' ') 

s[ i ] = ' ' is always true because the result of an assignment is the value assigned (space). This value is implicitly converted to a bool (0 = false, anything else = true). Since a space is 32 in ASCII, it will always be true.

ReferencesAssignment Operator, Comparison Operators, ASCII Table

solved The array index doesnt show the character [closed]