Originally Posted by
std10093
On line 19, you are comparing two strings with the operator !=
Or rather, that was probably what you were trying to do. In reality, you wrote this:
Code:
if ((string[i] =! string[j])){
which can be written as:
Code:
if (string[i] = !string[j]){
which is equivalent to:
Code:
string[i] = !string[j];
if (string[i]){
The result of !string[j] is an int, either 0 or 1. You then convert this int to a pointer, without a cast, in order to assign it to string[i].
Also, this is not good practice:
Code:
for (j = 0; string[j] != '\0'; ++j){
string is an array of pointers to char. Therefore, string[j] is a pointer to char. You compared string[j] to '\0', but '\0' is a character literal (i.e., of type int). If you want to check if string[j] is not a null pointer, either write:
Code:
for (j = 0; string[j]; ++j){
or more explicitly:
Code:
for (j = 0; string[j] != NULL; ++j){