So I'm working on pset2's Caesar and wanted decided it would be better to put the algorithm into functions, with each function operating based on whether a character is uppercase or lowercase. Now that I'm trying to integrate those functions into the main function, I get
error: expression result unused [-Werror,-Wunused-value]
For each function. Maybe I'm just making this more complicated than I need to, or maybe I'm going in a totally wrong direction, but these are the last two errors I have to clear. Here's my code:
#include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
void lowercase(char character);
void uppercase(char character);
int big_letters = 65;
int small_letters = 97;
//int key = argv[1];
int enciph_Len;
string encipher;
//void lowercase(int n);
int key;
int main(int argc, string argv[ ])
{
if (argc != 2)
{
printf("ERROR: COMMAND LINE ARGUMENT NOT ENTERED. EXITING \n");
return 1;
}
printf("Enter message you want enciphered:\n");
encipher = get_string();
enciph_Len = strlen(encipher);
key = atoi(argv[1]);
for (int i = 0; i < enciph_Len; i++){
if (isalpha(encipher[i]) ){
if(isupper(encipher[i])){
uppercase(encipher[i]);
} else if (islower(encipher[i])){
lowercase(encipher[i]);
}
printf("%c", encipher[i]);
} else {
printf("%c",encipher[i]);
}
}printf("\n");
printf("%i\n", key);
}
void uppercase(char character){
(character+key) % 26 + big_letters;
}
void lowercase(char character){
(character+key) % 26 + small_letters;
}
Then I get this after trying to make/compile the program:
~/workspace/pset2/caesar/ $ make caesar
clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0
-std=c11 -Wall - Werror -Wextra -Wno-sign-compare -Wshadow
caesar.c -lcrypt -lcs50 -lm -o caesar
caesar.c:59:30: error: expression result unused [-Werror,-Wunused-value]
(character+key) % 26 + big_letters;
~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
caesar.c:63:30: error: expression result unused [-Werror,-Wunused-value]
(character+key) % 26 + small_letters;
~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
2 errors generated.
make: *** [caesar] Error 1
Thanks for any help!