I have a file.txt that it contais, for example, "This is a txt file" (this content can be variable) and I need a function that reads file.txt and save its content into a char\*.

file.txt contains -> "This is a .txt file"

and I need a char \*readedContent that contains "This is a .txt file". 

First, I save the content of the char \*str (str contains "this is a .txt file") into a "file.txt" and then I try to get the string from this file but the string have more chars than "This is a .txt file". (Often add characters like spaces or @,?)

My function is:

```
char *special_char_remplace(char *str){

    FILE *f1;
    f1 = fopen("file.txt","w+"); 
    fprintf(f1,"%s", str);
    fclose(f1);

    size_t len, bytesRead;
    char *readedContent;
    FILE* f2;

    f2 = fopen("file.txt", "rb");

    fseek(f2, 0, SEEK_END);
    len = ftell(f2);
    rewind(f2);

    readedContent = (char*) malloc(sizeof(char) * len + 1);
    readedContent[len] = '\0'; // Is needed only for printing to stdout with printf

    bytesRead = fread(readedContent, sizeof(char), len, f2);

    printf("STRING: %s\n",  readedContent);

    fclose(f2);

    return readedContent;
}

```

The problem that I have is that in the char \*readedContent I have more chars than the file.txt's content.

Thanks very much.