how should I print the contents of a file on the console in C?

I've used fprintf and fopen to write stuff to the file, but now I want to display whatever i've written in that file onto the console. How should I do that? Thanks!

1 Answer

  • 1 decade ago
    Favorite Answer

    the printf function will print a string to the console.

    printf (string)

    printf( string, variable)


    printf("hi \n");

    //output is "hi"

    double h = 123.45;

    printf( "The value is %d \n", h);

    //%d is the data format

    //output is "The value is 123.45"

Still have questions? Get your answers by asking now.