GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


i get garbage at the end of my buffer somehow.... by godecho
1
 
FILE *stream = fopen(filename, "r");

if(stream)
{
    fseek(stream, 0, SEEK_END);
    int size = ftell(stream);
    fseek(stream, 0, SEEK_SET);

    if(size > 0)
    {
        char *buffer = new char[size];
        fread(buffer, sizeof(char), size, stream);
        printf(buffer);
    }
}