Concept
Why can’t numeric comparison operators be used to compare strings in C?
ComputerScienceOne / Comparing Strings and Characters
"Numeric comparison operators cannot be used to compare strings in C. For example, we could write (\"aardvark\" < \"zebra\") which would be valid C, and it would even have a result. However, that result wouldn’t necessarily be true or false . The reason for this is that strings in C are actually represented as arrays, which in turn are represented as memory locations . We’ll explore these issues in greater depth later on, but for now 273"
Related Ideas
- Why can’t numerical comparison operators be used to compare strings in C?ComputerScienceOne · Comparisons
- Why can numeric comparison operators not be used to compare strings in C?ComputerScienceOne · Order of Precedence
- How does strcmp() compare the contents of two strings in C?ComputerScienceOne · Comparisons
- How are comparison operators used with characters in C?ComputerScienceOne · Order of Precedence
- What do character comparison results show in C?ComputerScienceOne · If, If-Else, If-Else-If Statements
- How can you create an array of strings in C?ComputerScienceOne · Arrays of Strings
- How can qsort() sort an array of strings using pointers?ComputerScienceOne · Sorting Pointers to Elements
- What is a comparator function and how does it determine element order?ComputerScienceOne · Comparator Functions