I am currently facing a problem while coding. The problem is I want to loop through a string and compare each index with another string's index. And at the same time, copy the character to the other string if it does not have it yet. The code below is where I got stuck:
I compiled this and got the error: comparison between pointer and integer ('char' and 'string' (aka 'char *')) [-Werror,-Wpointer-integer-compare]
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[1])
{
string key = argv[1], key2[26];
for (int i = 0; key[i] != '\0' ; i++)
{
int j = 0;
if (key[i] != key2[j]) // I got an error here
{
key2[j] = key[i];
j++
}
}
printf("%s\n", key2);
}