How to write a C Program Basic logging of user input/output ?
Solution:
#include <stdio.h>
void main(void){
char fname[20];
char lname[20];
printf("Please Enter Your First Name: ");
scanf("%s", &fname);//This way will not include things after space
printf("Please Enter Your Last Name: ");
scanf("%s", &lname);//This way will not include things after space
FILE *f;
f = fopen("name.log","a");
fprintf(f,"%s %s \n",fname, lname);
fclose(f);
printf("Hello %s,\nYour name as been saved.\n", fname);
printf("=============================\n");
printf("Name Log Data\n");
printf("=============================\n");
char t;
f = fopen("name.log","r");
while((t = fgetc(f)) != EOF )
printf("%c", t);
fclose(f);
printf("-------------------------------\n");
printf("Please Press Enter to Continue.");
getchar();
getchar();
}
C Program Quadratic equation
Learn More :
Output
- DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM
- C Program to Save output of system command to variable with popen
- C Program File Input & Output Example
- C Program To Print String In Formatted Output Form
- C Program Nested Loop (inverted Triangle) C Code
- A small I/O bound program to copy N bytes from an input file to an output file.
Input
- C Program to Get User Input and Compare
- C Program File Input & Output Example
- C Program To Input & Print More Than One Words In Single Line
- Take microphone input and send to headphones
- A small I/O bound program to copy N bytes from an input file to an output file.
- C Program That in a Given Natural Number x Insert Figure c at Position p
- Input reads in the array positions and range for random generation.
- C Program that prompts the user to input a string, (whitespaces allowed)
- C Program to Input Number by the user between 1-100
- How to Gets User Input For Height in C Programming
- DEMULTIPLEXER CO ANALOG INPUTS
- C Program to Simulation program for FCFS ( First Come First Serve )
- C Program to Input Student Details into a File For Two Subjects
- Program to Display Pie Chart Accepting User Input C Program
- Input a Number and Check if it's Palindrome or not C Program
- Input Number and Print it's Reverse C Program
- Input Number and Check if it's Armstrong C Program
- Input Number and Check if it's Even or Odd C Program
- Input Two Numbers and Print Greater Number C Program
- Input Number and Calculate Sum of it's Digits C Program