Skip to main content
added 224 characters in body
Source Link
C4zZ
  • 37
  • 1
  • 5

check50 failures

enter image description here

And when I click on cat.html this happens...

check50 failures

enter image description here

And when I click on cat.html this happens...

added 1356 characters in body
Source Link
C4zZ
  • 37
  • 1
  • 5

UPDATE

I've tried to make the load function smaller without using my own addByte() function. Instead I used the BYTE* buffer variable as an array and added each b from the for-loop of my first load function for(int b = fgetc(file); b != EOF; b = fgetc(file))etc. on the i'th place of buffer. Here is my current code:

bool load(FILE* file, BYTE** content, size_t* length)
{
    
    int i = 0;
    size_t fileSize = 0;
    *content = NULL;
    BYTE *buffer = NULL;
    
    for(int b = fgetc(file); b != EOF; b = fgetc(file)){
        
        fileSize++;
        
        buffer = realloc(buffer, fileSize);
        
        buffer[i] = b;
    
        i++;
        
    }
    
    *length = fileSize;
    *content = buffer;
    
    return true;
}

The only thing I found out in the last days was that feof(file)'s integer value is 0 and the integer value of EOF is -1. Due to the fact that no functions like stcpy() or memcpy() are used I think that there is something basic I don't understand. Maybe it is simple pointer arithmetic? Maybe I don't understand realloc()? Maybe it is something with the null-terminator \0 or I don't understand a concept fully yet. I'm starting to freak out honestly.

UPDATE

I've tried to make the load function smaller without using my own addByte() function. Instead I used the BYTE* buffer variable as an array and added each b from the for-loop of my first load function for(int b = fgetc(file); b != EOF; b = fgetc(file))etc. on the i'th place of buffer. Here is my current code:

bool load(FILE* file, BYTE** content, size_t* length)
{
    
    int i = 0;
    size_t fileSize = 0;
    *content = NULL;
    BYTE *buffer = NULL;
    
    for(int b = fgetc(file); b != EOF; b = fgetc(file)){
        
        fileSize++;
        
        buffer = realloc(buffer, fileSize);
        
        buffer[i] = b;
    
        i++;
        
    }
    
    *length = fileSize;
    *content = buffer;
    
    return true;
}

The only thing I found out in the last days was that feof(file)'s integer value is 0 and the integer value of EOF is -1. Due to the fact that no functions like stcpy() or memcpy() are used I think that there is something basic I don't understand. Maybe it is simple pointer arithmetic? Maybe I don't understand realloc()? Maybe it is something with the null-terminator \0 or I don't understand a concept fully yet. I'm starting to freak out honestly.

edited title
Link
C4zZ
  • 37
  • 1
  • 5

Two compact versions of my load function doesn'tdon't work, help

added 559 characters in body; edited title
Source Link
C4zZ
  • 37
  • 1
  • 5
Loading
Source Link
C4zZ
  • 37
  • 1
  • 5
Loading