File Example - C Program

Program:
#include <stdio.h>
#include<string.h>
main()
{
    FILE *point;
    char str[35];
    int i, count;
    strcpy(str, "http://2k8618.blogspot.com/");
    point = fopen("file1.txt", "a");        // open in append mode
    for (count = 1; count <= 10; count++)
    {
        for (i = 0; str[i]; i++)
            putc(str[i], point); // output a single character
        putc('\n', point);       
       }
    fclose(point);
}

Output:
nn@linuxmint ~ $ gcc c26.c
nn@linuxmint ~ $ ./a.out
(file1.txt)
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/
http://2k8618.blogspot.com/

1 comment:

  1. I would like to thank you for the efforts you have made in writing this article.

    Friv.Pro
    Run3.me

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...