Write File
eharetea

Write data to a file in C.

Write data to a file.

Date Created:Tuesday February 27th, 2007 09:04 PM
Date Modified:Saturday August 02nd, 2008 01:42 PM


/*
*
* Writes a file!
* Author: Dan Lynch
*
*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
        char filename[1024];
        FILE *dan;

        printf("Enter a Filename:\n");
        scanf("%s", &filename);

        strncat(filename".c", (strlen(filename)+2) );

        dan fopen filename"w" );
        if ( dan == NULL )
        {
                printf("Cannot open file!");
        }
        fprintf(dan,"Test");
        fclosedan );

    return 0;
}



Downloads:
Download: writefile.c 507 B

Please login or Click Here to register for downloads
Creative Commons License
Write File by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com