I'm solving the Vigenere Cipher of Pset2, but when I compile the program, it shows an error:
format specifies type 'int' but the argument has type 'unsigned long' [-Werror,-Wformat]
I am not sure what this error message means, I Googled the error message, but I don't quite understand, can anyone tells me what's that about? Thank you.
Below is my code:
#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
//Declare variables
string key;
string text;
//check user's input value
int main (int argc, string argv[])
{
if(argc != 2)
{
printf("Please insert ONE key\n");
return 1;
}
for (int i = 0, n = strlen(argv[1]); i < n; i++)
{
if(!isalpha(argv[1][i]))
{
return 1;
printf("Please insert an ALPHABETICAL key\n");
}
}
//Get the text
text = GetString();
key = argv[1];
//cipher
for(int j = 0, l = strlen(text); j < l; j++)
{
if(isalpha(text[j]))
{
for(int p = 0, m = strlen(key); p < m; p++)
{
if(isupper(text[j]))
{
printf("%c", ((((text[j] - 65) + key[p]%strlen(key))% 26) + 65));
}
else
printf("%c", ((((text[j] - 97) + key[p]%strlen(key))% 26) + 97));
}
}
else
printf("%c", text[j]);
}
printf("\n");
return 0;
}