****Using C and only C****
I have some C code that has the function addRecord, to add a record to a linked list of records. However, when I run it, the program exits after asking the user to input the address. See picture below:

Here is my code:
#include<stdio.h>
#include<stdlib.h>
struct record
{
int accountno;
char name[25];
char address[80];
struct record* next;
};
void addRecord(struct record* newRecord) //Function For Adding
Record at last in a SinglyLinkedList
{
struct record *current,*start,*temp; //DeclareStructure Record
Variables,
//Allocating Dynamic Memory Location
if(newRecord == NULL)
{
printf("Failed to Allocate Memory");
}
else
{
printf("Enter the Record Details: \n"); //Reading The Record
Details
printf("Enter Account number:");
scanf("%d",&newRecord->accountno);
printf("Enter The Name:");
scanf("%s",&newRecord->name);
printf("Enter The Address");
scanf("%s",&newRecord->address);
newRecord->next=NULL; //Pointing to Next Record to NULL
if(start==NULL)
{
start=newRecord; //Pointing Starting Record if Starting record is
NULL
current=newRecord; //Current Record Becomes First Record
}
else
{
temp = start;
while(temp->next!=NULL)
{
temp = temp->next;
}
temp->next = newRecord;
}
}
}
int main()
{
struct record * test = (struct record *)malloc(sizeof(struct
record));
addRecord(test);
return 0;
}
PLEASE FIX what is going wrong in my code. Your help is appreciated.
If you have any doubts, please give me comment...
#include <stdio.h>
#include <stdlib.h>
struct record
{
int accountno;
char name[25];
char address[80];
struct record *next;
};
struct record *start = NULL;
void addRecord(struct record *newRecord) //Function For Adding Record at last in a SinglyLinkedList
{
struct record *current, *temp; //DeclareStructure Record Variables,
//Allocating Dynamic Memory Location
if (newRecord == NULL)
{
printf("Failed to Allocate Memory");
}
else
{
printf("Enter the Record Details: \n"); //Reading The Record Details
printf("Enter Account number:");
scanf("%d", &newRecord->accountno);
printf("Enter The Name:");
scanf("\n%[^\n]s", newRecord->name);
printf("Enter The Address: ");
scanf("\n%[^\n]s", newRecord->address);
newRecord->next = NULL; //Pointing to Next Record to NULL
if (start == NULL)
{
start = newRecord; //Pointing Starting Record if Starting record is NULL
current = newRecord; //Current Record Becomes First Record
}
else
{
temp = start;
while (temp->next != NULL)
{
temp = temp->next;
}
temp->next = newRecord;
}
}
}
int main()
{
struct record *test = (struct record *)malloc(sizeof(struct record));
addRecord(test);
printf("\n\nAccount No: %d\nName: %s\nAddress: %s\n", test->accountno, test->name, test->address);
return 0;
}

****Using C and only C**** I have some C code that has the function addRecord, to...
Using C, I need help debugging this program. I have a few error messages that I'm not sure how to fix. Here is the code I have: /* * C Program to Print a Linked List in Reverse Order */ #include <stdio.h> #include <stdlib.h> struct node { int num; struct node *next; }; int main() { struct node *p = NULL; struct node_occur *head = NULL; int n; printf("Enter data into the list\n"); create(&p); printf("Displaying the nodes in the list:\n");...
C LANGUAGE I just need the void push() function, which inserts new node to the front of the list #include<stdio.h> #include<stdlib.h> typedef struct node { int data; struct node *next; } Node; //Creating head a as a global Node* Node *head; /* Given a node prev_node, insert a new node after the given prev_node */ void insertAfter (Node * prev_node, int new_data) { /*1. check if the given prev_node is NULL */ if (prev_node == NULL) { printf ("the given...
Here is a function for some code im working on in C. Right now it accepts 2 different user inputs and stores them as city and distance. What I want is for the user to input only once. For example "Enter the city name and distance from previous city: Arlington 200". I need to separate that string into values for city and distance. I think I need to use tokens but im not sure how. void addCity () { char...
I have a C++ code that lets me enter, display and delete a
student record. I need to implement a function that prints the
average grade score of the students I input.
Below is my code and a picture of how my code looks right
now.
#include<iostream>
#include<stdlib.h>
using namespace std;
//Node Declaration
struct node
{
string name;
string id;
int score;
node *next;
};
//List class
class list
{
private:
//head...
URGENT. Need help editing some C code. I have done most of the code it just needs the following added: takes an input file name from the command line; opens that file if possible; declares a C struct with three variables; these will have data types that correspond to the data types read from the file (i.e. string, int, float); declares an array of C structs (i.e. the same struct type declared in point c); reads a record from the...
Please follow the information here, explain your answer, and
show that your code works. Your help is much appreciated.
Write the pseudocode of the a function, deleteRecord, to delete a record in the linked list of records. Assume the following variables are already defined, initialized and available for you to use: start: The pointer to the first record of the list (or NULL) uaccountno: The user's account number (integer) Assume the following struct definition: struct record int char char struct...
// C code // If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // Yyou are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of patients struct patientList { struct patient *patient; struct patientList *next; } *list = NULL; ...
Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...
I need to make it so this program outputs to an output.txt, the program works fine, just need it to fprintf to output.txt #include <stdio.h> #include <string.h> #include <malloc.h> #define MAX 30 struct treeNode { char names[MAX]; struct treeNode *right; struct treeNode *left; }*node; void searchName(char names[], struct treeNode ** parent, struct treeNode ** location) { struct treeNode * ptr, * tempPtr; if(node == NULL) { *location = NULL; *parent = NULL; return; } if(strcmp(names, node->names) == 0)...
Q 1.
Q 2.
if it works, I'll thumb up for u.
Complete the function createStudent below: #include <stdio.h> #include <stdlib.h> struct student { char name[50]; int age; struct student *next; }; struct student * createStudent(char studentName[], int studentAge) { } int main() { struct student *studptr; int myAge; char myName[50]; scanf("%s %d", myName, &myAge); studptr = createStudent(myName, myAge); printf("Student %s is %d years old.\n", studptr->name, studptr->age); free(studptr); return 0; } For example: Test Input Result Zhangwei Student Zhangwei is...