Write a C program that creates a file newfile in the current

Write a C program that creates a file \"newfile\" in the current directory containing 25 lines of identical text \'\'abcdefghijklmnopqrstuvwxyz\".

Solution

#include <stdio.h>

void main()
{
     FILE *fptr;
     /* open for writing */
    fptr = fopen(\"newfile.txt\", \"w\");
    if (fptr == NULL)
    {
        printf(\"File does not exists \ \");
        return;
    }
    //write content to file
    for(int i=0;i<25;i++)
    {
        fprintf(fptr, \"abcdefghijklmnopqrstuvwxyz\ \");
    }
}

 Write a C program that creates a file \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site