Question

The question is about C Programming. Can you give me an example in c, the requirements...

The question is about C Programming.
Can you give me an example in c, the requirements are:
The program need to provide users with the ability to create an account. An account should be a structure type variable containing: a username, a password.
Please provide more explains about some steps, and write in C.
Thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the desired C program, where we use linked list to create entry for new record.

#include<stdio.h>

struct account { //defining structure for account

char username[15];

char password[15]; //assuming username, password are 15 letters atmost

struct account *next; //pointer to next element in linked list

};

struct account *Root; //creating global pointer for root of linked list

//Now below function will take as input, the root of linked list and add a new account at the last entry of linked list

void add_account(struct account *root, char *uname, char *passwd)

{

struct account *temp;

if (root==NULL) //means linked list is empty

{

root = (struct account *) malloc (sizeof (struct account ));

strcpy (root->username, uname); //copy uname provided

strcpy (root->password, passwd); //copy passwd provided

root->next = NULL; //set next node to be NULL

return ; //Return from this function

}

else { //when linked list is not empty

temp = root; //initialize temp variable with root node

while (temp->next != NULL) //go to the last element of linked list

{

temp = temp->next; //proceed till the end of linked list

}

temp->next = (struct account *) malloc (sizeof (struct account)); //create space for new account

temp = temp->next; //now switch to new element and add entry

strcpy (temp->username, uname); //copy the username

strcpy(temp->password, passwd);// copy the password

temp->next = NULL; //set the next pointer of last element to NULL

return;

}

}

Please comment for any clarification.  

Add a comment
Know the answer?
Add Answer to:
The question is about C Programming. Can you give me an example in c, the requirements...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The question is about C Program. The program should provide users with the ability to create...

    The question is about C Program. The program should provide users with the ability to create an account. An account should be a structure type variable containing: a username, a password. Please try to avoid using global printers and write in C. Thank you very much!

  • Good evening, here is a C program question. I wanna to write a very small game....

    Good evening, here is a C program question. I wanna to write a very small game. The rule of the game is like rock scissors. Both of the player and the computer generate a letter taking the value A, B, C. And A<B, B<C, C<A (Like rock scissors game, rock<cloth, cloth< scissor, scissor<rock) Requirement 1: New users need to register an account with a username and password. Actually, the account should be a structure type variable containing: a username, a...

  • ATM MACHINE

    Kindly help me In this assignment you will create a RMI based system that allows a user to do the following: 1) Create a bank account by supplying a user id and password. 2) Login using their id and password. 3) Quit the program. Main Manu of ATM service window *Separate remote methods will be created for all of these functionalities. ->To create account see output below Hi! Welcome to  ATM Machine! Please select an option from the menu below: l -> Loginc -> Create New Account q -> Quit > c...

  • PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program...

    PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program to hold information about the gemstones he has in his safe. Offer the jewelry designer the following menu that loops until he chooses option 4. 1. Input a gemstone 2. Search for a gemstone by ID number 3. Display all gemstone information with total value 4. Exit ------------------------------------- Gemstone data: ID number (int > 0, must be unique) Gem Name (string, length < 15)...

  • Programming Problem 1 - File Name: pass.cpp (5 pts.)        Description: You were hired by...

    Programming Problem 1 - File Name: pass.cpp (5 pts.)        Description: You were hired by the KFU cybersecurity team to create a program that checks if the passwords chosen by users are strong or not. A password is considered strong if the following conditions are satisfied: •   Its length is at least 8 characters •   It contains at least one uppercase letter. Input Format: The program will prompt the user to enter their chosen password. Example Input Enter your...

  • Lab 4: Databased Admin Tool Continued Python Objective: In the previous lab, you developed an admin tool for username an...

    Lab 4: Databased Admin Tool Continued Python Objective: In the previous lab, you developed an admin tool for username and password management. You accomplished the tasks with Dictionary or List. Here, use class to design your own data structure to accomplish a similar task. The UD.txt datafile: FIRST NAME, LAST NAME,USERNAME,PASSWORD Sam, DDal,sdd233,Pad231 Dave, Dcon,dcf987, BHYW4fw Dell, Grant,dgr803,Sb83d2d Mike, Kress,mkr212,UNNHS322 Lisa,Kate,lki065,dgw6234 Paul,Edward,ped332,9891ds Youyou,Tranten,ytr876,dsid21kk Nomi,Mhanken,nmh223,3282jd3d2 Write a program that imports the database from UD.txt, your program can search for users’ password....

  • USE RAPTOR PLEASE Could you please help me to create a FLOWGORRITHM for the following information?...

    USE RAPTOR PLEASE Could you please help me to create a FLOWGORRITHM for the following information?   I need only FLOWGORRITHM showing flowchart with PICTURES (STEPS). Please help me You are writing a FLOWGORRITHM program that will act like an ATM machine. In order to access the ATM, the customer must enter their user name and their passcode. The list of legitimate users along with their user ID, passcode and account balance is provided to you below. There are only 3...

  • Here are requirements of a C code. I think it is not difficult for you because...

    Here are requirements of a C code. I think it is not difficult for you because i have deleted some requirements. (I think it will be better if user can choose their identification once runned). Please write in C and give some explains! Overall description: Your team is employed by a bank to implement a system to manage the banking affairs. Customer specifications: The implementation of the banking system should be able to provide facilities to: • Register a new...

  • Can someone complete this program for me in c programming language? Thank you! The Send-Ex Shipping...

    Can someone complete this program for me in c programming language? Thank you! The Send-Ex Shipping Company charges the following rates: Weight of Package 2 lbs or less Over 2 lbs but no more than 6 lbs Over 6 lbs but no more than 10 lbs Over 10 lbs Rate per Pound $1.10 $2.20 $3.70 $4.10 Write a program that asks the user to enter the weight of a package and then displays the total shipping charge. Reserve Point Opportunity/...

  • Please create a program answering the following question. In C PROGRAMMING! Contactlnformation Create a program with...

    Please create a program answering the following question. In C PROGRAMMING! Contactlnformation Create a program with the following requirements 1. You must have a data structure for personal contact information 2. Declare one of your contact information data structures locally in main 3. Create a function that allows users to enter in all of the information that populates the data structure that was passed in 4. Create a function that displays the information that was entered into the data structure...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT