I am trying to compare two strings in my program so that I can arrange them in dictionary order. I am not allowed to declare an array like this: string arr[10]
, instead I have to declare it like this: char arr[10][20]
, where the [10]
denotes the number of strings and the [20]
denotes the size of each string.
To compare two strings I tried using something like: arr[5]>arr[7]
, but it didn't work. Any ideas?
https://www.techonthenet.com/c_language/standard_library_functions/string_h/strcmp.php
strcmp() should do the trick
Since you are limited to char arrays instead of string literals look at C documentation instead of C++ documentation. I assume you are a student as I had the same limitations.