Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Extend the code below using online GDB that simulates and prints user login records so that the information about the user's terminal is also stored

Extend the code below using online GDB that simulates and prints user login records so that the information about the user's terminal is also stored in the file and then printed. Your program output should look like this:
user_0 last logged in on terminal_10 on Mon Jun 313:10:532024
user_1 last logged in on terminal_11 on Mon Jun 313:10:542024
user_2 last logged in on terminal_11 on Mon Jun 313:10:552024
You are not allowed to use any file IO functions other than the system calls discussed in class.
Submit a single C source code file with your work and a screenshot (in PNG or JPG format) showing the results of executing your program.
// using structures in C
#include
#include
struct dataRecord {// a simple structure to represent a person
int intID;
int intAge;
float fSalary;
char strName[100];
};
// print the values of a structure
void printDataRecord(const struct dataRecord * p){
printf("%s is %d years of age, their salary is %f.
",
p->strName, p->intAge, p->fSalary);
}
int main(){
struct dataRecord John; // declare an instance of a structure
John.intID=12345;
John.intAge=25;
John.fSalary=100.05;
strcpy(John.strName,"John");
printDataRecord(&John);
John.intAge=26; // change one field within a structure
struct dataRecord *alias=0;
alias=&John; // create a pointer to a structure
alias->fSalary=110; // access a field within a structure via a pointer
printDataRecord(&John);
(*alias).fSalary=115;
printDataRecord(alias);
return 0
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

OUTCOME 2 Describe how a training needs assessment should be done.

Answered: 1 week ago