-->

program to understand fclose() with stdout

using codeblocks
---------------------------------------------------------------------------------------------------------
//understanding fclose() in the sense of stdout.
#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello world!\n");       //prints hello world
    fclose(stdout);                 // closes the data to be written to device
    printf("goodbye");               //does not print good bye.
    return 0;
}

------------------------------------------------------------------------------------
using turboc++
--------------------------------------------------------------------------------
//understanding fclose() in the sense of stdout.
#include <stdio.h>
#include <conio.h>

int main()
{
    printf("Hello world!\n");       //prints hello world
    fclose(stdout);                 // closes the data to be written to device
    printf("goodbye");               //does not print good bye.
    getch();
    return 0;
}

No comments:

Post a Comment