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/

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...