Question

Create a c file to read a character from the keyboard and write it to a...

Create a c file to read a character from the keyboard and write it to a file.
please help

Homework Answers

Answer #1

Please look at my code and in case of indentation issues check the screenshots.

---------------main.c----------------

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


int main()
{
   char ch;
   printf("Enter a character: ");
   scanf("%c", &ch);                               //read the character from user

   FILE *outfile = fopen("output.txt", "w") ; //open file for writing
   fprintf(outfile, "%c", ch);                    //write the character into file
   printf("The character was written to output.txt successfully\n");
   return 0;
}


--------------Screenshots--------------------

------------------Output------------------

---------------------------------------------------------------------------------------------------------
Please give a thumbs up if you find this answer helpful.
If it doesn't help, please comment before giving a thumbs down.
Please Do comment if you need any clarification.
I will surely help you.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a file that has a series of ten strings in it, all accepted from the...
Create a file that has a series of ten strings in it, all accepted from the user through the keyboard. Then, open that file in read mode, and reverse the order of the characters in each line, saving the reversed line to a new file. Display the completed reversed file when done. Need help this done in PERL language. Thank you
C++ code: How to add a file to read/write to a code that prompt user to...
C++ code: How to add a file to read/write to a code that prompt user to add (write) infos and read infos from the file?
1.      Create 100 text files automatically; in each file write a random number from 1 to 10....
1.      Create 100 text files automatically; in each file write a random number from 1 to 10. Use outputstreams (fileoutputstream, buffredwriter….) 2.      Read the content of the 100 files and combine them into a 1 single file. 3.      Write java code to do the following: a.      To write the following text into a text file EEEESAAA@23SDCFSAWERF%WASDFGHWERTRQW b.      Read the file using a java program c.      Find how many D’s in the file d.      Extract the text between the @ and the # 1. Create 100 text files...
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
Write a MARIE assembly program to read three different positive numbers from the keyboard and output...
Write a MARIE assembly program to read three different positive numbers from the keyboard and output the difference between the largest and smallest numbers to the screen.
C++ create a program that: in main: -opens the file provided for input (this file is...
C++ create a program that: in main: -opens the file provided for input (this file is titled 'Lab_HW10_Input.txt' and simply has 1-10, with each number on a new line for 10 lines total) -calls a function to determine how many lines are in the file -creates an array of the proper size -calls a function to read the file and populate the array -calls a function to write out the contents of the array in reverse order *output file should...
(a) Write a function in C++ called readNumbers() to read data into an array from a...
(a) Write a function in C++ called readNumbers() to read data into an array from a file. Function should have the following parameters: (1) a reference to an ifstream object (2) the number of rows in the file (3) a pointer to an array of doubles The function returns the number of values read into the array. It stops reading if it encounters a negative number or if the number of rows is exceeded. (b) Write a program with the...
C++ Write a program which accepts a character from the user. If the character is between...
C++ Write a program which accepts a character from the user. If the character is between 0 and 9, it will output that it's a digit. If the character is lowercase it will output that its a lowercase character. If it's an uppercase character it will output that it's uppercase. For all other cases it will output that it's neither a digit nor a letter. As an example of the output: Enter a digit or a letter: A You entered...
Using PUTTY We will create functions.h and functions.cpp to separate the read and write function from...
Using PUTTY We will create functions.h and functions.cpp to separate the read and write function from main function. Use the following steps:o Create a directory called lab07o Upload the yourlastnameFirstnameLab06a.cpp from your computer to the csegrid. Create a functions.h file with the following: #ifndef _READWRITE #define _READWRITE void readWrite( ); #endif Create a functions.cpp#include functions.hImplement readWrite() with the code in case 1 of the main.cpp. Modify yourlastnameFirstnameLab06a.cpp #include functions.h Call readWrite for case 1 (instead of the case1 code) Compile...
C LANGUAGE Create your own library named cis340yourlastname. Create a header file named cis340yourlastname. Write a...
C LANGUAGE Create your own library named cis340yourlastname. Create a header file named cis340yourlastname. Write a program that receives two numbers from the user and uses your written library to calculate the reminder after division, the addition, and the subtraction of these two input numbers. (Hint your library should include three functions. Your header file should not contain the code for any of these functions, it should contain only the instructions for how to use the library).
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT