Question:

NEED HELP WITH C PROGRAMMING!~!~!

by  |  earlier

0 LIKES UnLike

Write a C program that opens two data files one for reading and another for

writing. The program must copy the contents of input data file to output file

with the data double line spaced. Example below. The program must work

for all data files [ and not just for the following example ]

Input file:

Earth is Solid

So is Moon.

Output File:

Earth is Solid

So is Moon.

 Tags:

   Report

2 ANSWERS


  1. my rate is 15c/min


  2. #include <stdio.h>

    main() { int c; while ((c = getchar()) != EOF) { putchar(c); if (c == '\n') putchar(c); }

    gcc -o prog prog.c

    I haven't compiled this.  Debugging is up to you.  If this is an assignment, you should modify it to look good, and you should understand it.  Look up the calls.  You might have it actually open the input file, and write to an output file.  There may be compiler warnings.  Study them.

    It gets a character at a time and writes that to stdout.  If the character is a newline, it emits a second newline. Why did i use an int instead of a char for the character?  Does it work with a char?  I'll give you a hint.  It should work on an x86, but not an Arm.  It's not much of a hint.

    From the command line:

    prog < file

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.