I have 2 errors in the if else loop and i don't konow what? Thanks for help me. I am a beginnner.
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char* argv[])
{
if (argc != 2)
{ printf("USAGE: cipher <integer key> <encode | decode>\n");
printf("Then, just type your text and it will automatically output the en/de crypted text! :)\n");
return 1;
}
int key = atoi(argv[1]);
string s = GetString();
if (key > 25)
{
key = key%26;
for (int i = 0, longitud = strlen(s); i < longitud; i++)
{
int chr = 's[i]';
if (!isalpha(s[i]))
{
printf("'%c'", chr);
else
if (( s[i] >= 'a' && s[i] <= 'z'))
{
chr = (chr -'a' + key) % 26 + 'a';
printf("'%c'", chr);
else
chr = (chr-'A' + key) % 26 + 'A';
printf("'%c'", chr);
}
}
}
else
for (int i = 0, longitud = strlen(s); i < longitud; i++)
{
int chr = 's[i]';
if (!isalpha(s[i]))
{
printf("'%c'", chr);
else
if (( s[i] >= 'a' && s[i] <= 'z'))
{
chr = (chr -'a' + key) % 26 + 'a';
printf("'%c'", chr);
else
chr = (chr-'A' + key) % 26 + 'A';
printf("'%c'", chr);
}
}
}
}
}
argv
isnull
AND if hislength
is good. – cl-r Jan 4 at 10:40if else loop
. – codesparkle♦ Jan 4 at 14:36