Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Using online GDB , please extend the C code below, and show a screenshot of the output! The code should simulate and print user login

Using online GDB,please extend the C code below, and show a screenshot of the output!
The code should simulate and print 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
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.
The Code:
// 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 with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

a sin(2x) x Let f(x)=2x+1 In(be)

Answered: 1 week ago