I am running the following code based on this answer: C: read only last line of a file. No loops
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <netinet/in.h>
 #include <unistd.h>
 #include <iostream>
 #include <cstring>  
 #include <stdlib.h>
 #include <stdio.h>
 main(){
 string answer= "Nothing, actually" 
 FILE* fd;
 if ((fd = fopen("result.txt", "r")) != NULL);
 static const long max_len = 55 + 1;
 char buf[max_len + 1];
 fseek(fd, -max_len, SEEK_END);
 ssize_t len = fread(fd, buf, max_len);
 buf[len] = '\0';
 char *last_newline = strrchr(buf, '\n');
 char *last_line = last_newline+1;
 answer= last_line;}
When I compile it via my makefile I get back:
tcp-server.cc:111:42: error: invalid conversion from ‘char*’ to ‘size_t {aka long unsigned int}’ [-fpermissive] ssize_t len = fread(fd, buf, max_len); ^ tcp-server.cc:111:42: error: too few arguments to function ‘size_t fread(void*, size_t, size_t, FILE*)’
I just want it to read the last line of a file. Have no idea why this is difficult or why I am getting the error. Edited to show update made after a comment that did fix one error, but not the current two.
 
     
    