C++ :: Input Data Of Object From User And Then Insert It In Linked List
May 16, 2013
Error:
--------------------Configuration: nc - Win32 Debug--------------------
Compiling...
cv.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/nc.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
nc.exe - 2 error(s), 0 warning(s)
Compiles with 0 error but on running 2 Errors appear.
I'm Inputting data of an object from user and then inserting it in the link list.
#include <iostream>
//#include <fstream>
using namespace std;
#define LEN 100
////////////////////////////////////////////////////////////////////////////////////////////////////
class employee{
[Code] ....
View 1 Replies
ADVERTISEMENT
Apr 14, 2014
I'm having a problem trying to modify my patient's data. It seems to work, but once the block of code ends it does not save to the linked list.
Problem located in case M.
linked list template header: [URL] ...
patient header: [URL] ...
patient implementation: [URL] ...
#include <iostream>
#include "listTemplate.h"
#include "PatientRecord.h"
using namespace std;
char menu() {
char input
[Code]...
View 1 Replies
View Related
Apr 19, 2013
I have a list of objects that I need to read information from each object to compare to a user input prompt.
#include "Passenger.h"
#include "Reservation.h"
#include "Aircraft.h"
#include <iostream>
#include <fstream>
#include <string>
#include <list>
using namespace std;
//Function Prototypes
void flightRoster(list<Reservation>&);
[Code] ....
View 1 Replies
View Related
Oct 25, 2013
I have a problem with inserting a node between two nodes.
Code:
#include <stdio.h>
#include <stdlib.h>
struct listelem {
int nbr;
struct listelem *next;
[Code] ....
View 8 Replies
View Related
Feb 17, 2013
I'm trying to make a function that lets me pass an index and a string and will insert the string at that index in the linkedlist... here is so function i have so far:
Code:
typedef struct node {
char* value;
struct node* next;
} LinkedList;
void llAddAtIndex(LinkedList** ll, char* value, int index) {
[Code] .....
View 4 Replies
View Related
Feb 12, 2014
I have a program and function i'm having an issue understanding. Here is what it's doing in the main.
int main() {
orderedLinkedList<MemberDO> memberList;
MemberDO::readFromFile("Member.dat", memberList);
return 0;
}
So it is creating a linked list object using the MemberDO class type which has a int, string, char and double. Then it will call the readFromFile static function in the MemberDO. So this is where my problem is I have this function
void MemberDO::readFromFile(char *fname, orderedLinkedList<MemberDO>& list) {
}
How do I read in each individual data member from the input then create a new MemberDO object and insert the objects into the linked list specified in the second argument list?
Here is the MemberDO class declarations
class MemberDO {
private:
int key;
string lastName;
char firstInitial;
double dues;
[Code] ....
View 4 Replies
View Related
Jul 26, 2013
I'm having trouble inserting a node in a nth position into a double linked list. My for loop is giving me an exception handler error and I can't link the node after the new node is inserted back to the new node. Here is my code,
void mylist::insertpos(const int &pos, const string &s, const int & c) {
listnode* temp1 = new listnode(s,c);
temp1->s =s;
temp1->next = NULL;
[Code]....
I attached my header file incase you need to see the definitions for my objects.
View 4 Replies
View Related
Oct 14, 2014
It is suppose to insert items in Linked List in sorted ascending order and no duplicates are allowed.The code complies but it creates duplicates out of order.
ListRetVal CSortedList :: InsertItem(const ListItemType &newItem)
{
ListItemNode* newLNode = new ListItemNode();
newLNode->value=newItem;
newLNode->next=NULL;
[Code].....
View 5 Replies
View Related
Feb 17, 2013
I'm still trying to insert a node at a passed index in a linked list. This is my function, it doesn't work but i feel like it's close.
Code:
void llAddAtIndex(LinkedList** ll, char* value, int index) {
LinkedList* newNode = (LinkedList*)malloc(sizeof(LinkedList));
newNode->value = value;
LinkedList* prevNode = *ll;
for(int i = 0; i < index; i++){
[Code] ....
View 2 Replies
View Related
Feb 8, 2014
How to randomly insert certain numbers into a linked list with 10 nodes. Meaning I want to put for example numbers 1 5 10 15 20 25 30 35 40 50 in random locations in the linked list.
View 1 Replies
View Related
Mar 16, 2014
is this correct? I used this sorting with numbers i don't know if it is the same with strings. When I run it, there are no errors detected, but when i try to view it, the inputs does not appear.
void add(node **h, node **t){
node *temp, *ptr;
char s[20];
temp = (node*) malloc(sizeof(node));
printf ("-INSERT-");
printf("Fruit: ");
scanf("%s", temp->fruit);
[Code] .....
View 1 Replies
View Related
Feb 20, 2014
I'm trying to figure out how to insert a node into a linked list at a particular location based on a time..I have this declared outside of everything globally.
Code:
struct aTime {
char name[LENGTH];
int time;
struct aTime* next;
};
struct aTime* head = NULL; And then this function that is used to add nodes (aTime structs) to a linked list. It adds the first node fine, but not subsequent ones. I think this is because I have while p-> != NULL but it is always going to be null when the function is called since I create a new aTime struct. So I guess my question is how, after one struct has been added at the beginning, do I point to the head node and traverse the list, insert a node, and make sure everything is still linked? Do I need another temp aTime struct?
Code:
void add_time(char name[LENGTH], int seconds)
{
struct aTime *p;
p = (struct aTime *) malloc(sizeof(struct aTime));
if (head == NULL)
{
strcpy(p->name, name);
p->seconds = seconds;
}
[code]....
View 3 Replies
View Related
Jun 29, 2013
I have a linked list comprised of chars like so...
Code:
node1 - "p"
node2 - "o"
node3 - "p"
I need a function that will take in three perameters...node *replaceChar(node *head, char key, char *str)Stipulations of this function. head is the head of the list, 'key' and 'str' are guaranteed to contain alphanumeric characters only (A-Z, a-z, and 0-9). str can range from 1 to 1023 characters (inclusively). So if I call this function with these perameters..
Code:
node *head == /*the head of the list to be examined*/
char key == "p"char *str == "dog"The new list will look like this...
node1 - 'd'
node2 - 'o'
node3 - 'g'
node4 - 'o'
node5 - 'd'
node6 - 'o'
node7 - 'g'
All instances of 'p' were replaced with 'dog' I have a toString function which takes in a string and converts it to a linked list and returns the head. So assume that you can call the function on str = "dog" so...
Code:
toString(str) == /*this will return the head to the list made from the str*/
If it's unclear what my question is...I am stumped on how to write the replaceChar function the one that takes in three perameters..
View 3 Replies
View Related
Dec 1, 2013
how to insert a variable for the size of array and prompt user to insert the elements for the array?
View 13 Replies
View Related
Feb 10, 2014
I have a standard linked list in template format (with T being the typename) with the following relevant insertion operators:
bool PushFront (const T& t); // Insert t at front of list
bool PushBack (const T& t); // Insert t at back of list
I want to build a list of pointers to objects (we'll call them objects of class Box for simplicity) that is member data for a parent class (we'll call that class Warehouse). However, I want to have a constant Box....const Box INVISIBLE_BOX = Box(); that represents a nonexistent Box. However, I cannot use either
PushFront(&INVISIBLE_BOX)
or
PushBack(&INVISIBLE_BOX)
to add INVISIBLE_BOX to the list of boxes without getting an invalid conversion error invalid conversion from âconst warehouse::Box*â to âwarehouse:: Box*â [-fpermissive]
What can I do to make it take a constant Box? I am using g++ to compile these files.
View 1 Replies
View Related
Feb 6, 2014
I am wanting to be able to add as many different instances of data, while the user has not stated 'n', but then it only ever writes back to the screen the input for the last set of data. Where as I want to display back to the screen all the data that has been entered.
Code:
#include <iostream>
#include <string>
/*Function Declaration*/
void createItem();
void returnItem();
//Items structure
[code]...
View 6 Replies
View Related
Aug 12, 2013
I'm trying to impliment a simple singly linked list, then allow a user to add a new node. I have mocked up a siimple example to illustrate my point using Linked Lists...
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
int x;
struct node *next;
[Code] ....
So I have done things similatr to this in C# and Java but not in C. There maybe some parts of this I'm sure some will disagree with in terms of buffers,overflow etc. but it's just the linked list part that I am interested in at the moment, I am only doing it like this because when it works, I will be extracting the working linked list stuff into another program that can deal with its I/O etc.
I have tried to comment as best I can to demonstarte my intentions and understandings per line of code. The add function needs to add a node of value x that the user has input, and add that to the end of the list - I'm sure that the print function is not doing all its supposed to do...
View 4 Replies
View Related
Sep 8, 2014
#include <iostream>
using namespace std;
void insert(int data, int positionOf_n);
void print();
struct node {
int data;
struct node *next;
[code]....
this is the original code which use the insert function call in the main as predefined that doesn't allow the user to input the value that they want
#include <iostream>
using namespace std;
void insert(int data, int positionOf_n);
void print();
struct node {
int data;
[code]....
and this the code which i tried to replace the limitation of the above code by using two for loops in the main function instead of the <insert(5,2)> from the above code which allow the user to insert it own values to the linked list, but it keeps crashing.
View 4 Replies
View Related
May 27, 2013
I have made a Student record system in c++ using the concept of linked list. The program will take the student id, name and marks for 3 different exams. Then it will calculate the aggregate percentage based on those exams marks and display the relevant message according to the aggregate percentage. All is going well. But there is only one problem. When I modify the student record especially the marks, it doesn't change the aggregate percentage of that specific record. It shows the old one. Similarly the relevant message doesn't change too.
Code:
struct student{
int id;
char name[MAX];
string status;
double aggr;
int matric_marks, inter_marks, entryTest_marks;
[Code] .....
View 3 Replies
View Related
Aug 6, 2014
How can I search the data? I want to get the output like this.
============================== Enter a data to search: 44 DATA FOUND! ==============================
Code:
#include <iostream>
using namespace std;
struct node {
[Code].....
View 1 Replies
View Related
Feb 9, 2015
I am unable to insert data in a linked lists. Show function is not working.
insert
Code:
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
int data;
struct node *next;
[Code] .....
View 7 Replies
View Related
Mar 20, 2014
The input is in the following format
5
1 2 9.0
1 3 12.0
2 4 18.0
2 3 6.0
2 5 20.0
3 5 15.0
0
1 5
The first number is the number of vertexes in the graph. Then next lines up to 0 are the edges of the graph. With the first and second numbers being the vertexes and the third being how far the edge is between them. Trying to read in the data and store the edges into there locations in the List adjacency for that vertex. This example would make a graph with five vertexes with edges from 1 to 2&3. 2 to 4&3&1 etc. It also stores in the opposites ex 2 1 9.0.
When reading it in and printing it back out it seems that it is only storing the last data entered for that vertex. EX. When trying to print out the data read in i only get 1 3 12.0, 2 5 20.0, 3 5 15.0, ( 4 2 18.0, 5 3 15.0 would show up if `if(i<n)` was removed it is there so it does not show duplicate edges). what I am doing incorrect?
// CSCI 3300
#include <cstdio>
using namespace std;
struct ListCell
{
ListCell* next;
int vertex;
double weight;
ListCell(int v, double w, ListCell* nxt)
[Code]...
View 1 Replies
View Related
Oct 26, 2013
I need an explanation of what linked lists are. How the nodes are been defined and used, especially in an object oriented programming. With a code example.
View 1 Replies
View Related
Mar 26, 2015
I have a data file that looks like:
111111111
Lisa
Porter
3
ENEE 114
CMSC 412
ENME 515
333333333
Alex
Simpson
1
CMSC 412
***
In the form student ID and then first name last name number of courses and finally the course code(s). Im currently attempting to read these into linked lists with the following code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct CourseInfo {
int courseID;
char courseName[30];
[Code] ......
I get no errors or warnings however when i print this out i get:
111111111
Lisa
Lisa
Porter
3
ENEE 114
CMSC 412
ENME 515
And then the program crashes. So i know that for some reason the problem is the
fgets(rootPtr->FirstName, 22, p);
But I do not know why because it seems to work for the other fgets. I also want to know why the while loop never runs and it crashes instead.
View 14 Replies
View Related
Dec 24, 2013
using the following header files:
Code:
#include <list>
#include <map>
#include <iostream>
#include <algorithm>
and
Code:
std::list
If there is a creation of a list, how can one find the sizeof the list. and is it possible to copy all the data from the linked list into an array. Assuming that the data is of type
Code:
char
View 1 Replies
View Related
Dec 30, 2012
What I'm trying to do is make a calculator that takes two large numbers in a linked list then ask the user if they wish to add them or subtract them.
#include<iostream>
#include<string>
using namespace std;
class Node {
public:
int value;
Node * next;
[Code] ....
View 5 Replies
View Related