I'm having some problems with making the vigenere assignment from CS50. I get many errors about my comparison between pointer and integer, how can I avoid this error? I also have some problems with the expression "if (strlen(plaintext(!=0)))", and don't seem to understand why.. Can you help me please?
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
int main(int argc, string argv[])
{
// faults when no good arguments are given
if (argc(! = 2))
{
printf("no good value entered!\n");
return 0;
}
if (!isalpha(argv[1]))
{
printf("No good value entered!\n");
return 0;
}
string key = (argv[1]);
//get plaintext from user: repeat untill some characters are given
do
{
printf("plaintext: ");
string plaintext = get_string();
}
while (strlen(plaintext) == 0);
// check if plaintext is given
if (strlen(plaintext(! = 0)))
{
printf("no right characters are detected\n");
return 0;
}
// encrypt plaintext
int keylenght = strlen(argv[1]);
for (int i = 0, j = 0, n = strlen(plaintext); i < n; i++, j++)
{
// start key again if shorter than plaintext
if (j >= keylenght)
{
j = 0;
}
// skip key [j] if plaintext[i] is not alpha
if (!isalpha(plaintext))
{
j = (j - 1);
}
// make Aa=0 and Zz=25 for uppercase
if ((key >= 'A') && (key <= 'Z'))
{
key = (key - 'A');
}
if ((key >= 'a') && (key <= 'z'))
{
key = (key - 'a');
}
string shift = (plaintext[i] + key);
// stopping at Z for uppercase
if ((isupper(plaintext[i]) && (shift > 'Z'))
{
shift = (shift - 26);
}
//stopping at z for lowercase
if ((islower(plaintext[i] && (shift > 'z'))
{
shift = (shift - 26);
}
// check if alpha --> print encrypted
if (isalpha(plaintext[i]))
{
printf("%c", shift);
}
// non-alpha --> just print
else
{
printf("%c", plaintext[i]);
}
}
printf("\n");
return 0;
}