C invalid initializer on empty line and invalid arguement on a while loop

Viewed 61

I am getting those following errors in this code I am not sure what causes them. Since one of them happens on an empty line where nothing happens. The other is on a while loop that doesn't take an argument I believe.

Error message: test.c: In function ‘main’:

test.c:28:15: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   28 |       checker = decrypt(Ciphertext,key,iv);
      |               ^
test.c:31:8: warning: format not a string literal and no format arguments [-Wformat-security]
   31 |        printf(key);
      |        ^~~~~~
/usr/bin/ld: /tmp/ccGWk1m2.o: in function `main':
test.c:(.text+0x57): undefined reference to `readWord'
/usr/bin/ld: test.c:(.text+0x8c): undefined reference to `decrypt'
collect2: error: ld returned 1 exit status
#include <stdio.h>
#include <stdlib.h>
#include <conf.h>
#include <evp.h>
#include <err.h>
#include <string.h>
#include <ctype.h>
unsigned char *readword(FILE *fp);
int decrypt(unsigned char *Ciphertext, unsigned char *key,unsigned char *iv);
int main (void)
{

    char *key = NULL;
    char *iv = "aabbccddeeff00998877665544332211";
    char *Plaintext = "This is a top secret.";
    char *Ciphertext = "764aa26b55a4da654df6b19e4bce00f4ed05e09346fb0e762583cb7da2ac93a2";
    char *checker;
    //  invalid initializer on this line for some reason
    FILE words;
       words = (fopen("words", "r"));

    while(1) {  // invalid argument when I am not even using one? it's C standard loop right?
        key = readword(words);
        if (!key){
            printf("the key was not found");
            break;
        }
        else{
            checker = decrypt(Ciphertext,key,iv);
            if(strcmp(checker,Plaintext)){
                printf("the correct key is ");
                printf(key);
            }
            free(key);
            free(checker);

        }
    }

    return 0;
}
0 Answers
Related