C++ :: Strcmp On Linked List Data And String Constants?

Sep 28, 2013

why strcmp() doesn't return true when comparing a string constant with a string that was acquired via a linked list. By the way, the data in the linked list was taken from a text file. Does that imply that there's a new line () character in the string from the linked list?

Code:
struct Node{
char ACNO[15];
struct Node *next;

[Code]....

View 1 Replies


ADVERTISEMENT

C++ :: Strcmp Function - Comparing String Data From Two Different Files

Dec 20, 2013

I am having a slight issue with the strcmp function. I am comparing string data from two different files. I want the function to output a set of information if the strings are the same and a different set of data if the strings are different. My issue is, the function outputs the data that's the same but not different.

I had an else statement that compared the data if it was NOT equal but it only duplicated the data in the file.

One file is a listing of 100 books with 10 lines of information and an assigned market. The second file is a listing of the markets contained in the books file. However, the books file has a market that is not located in the markets file. The "missing" market is what is not priting or displaying.

// final project2 file

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;
const int ARRAY_SIZE = 500;
const int MARKET_ARRAY = 6;
ifstream infile, infile2;
ofstream outfile;

[Code] .....

View 6 Replies View Related

Visual C++ :: Reading In Data And Displaying Out All Data In Linked List?

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

C++ :: How To Modify Data In A Linked List

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

C++ :: Search The Data In The Linked List?

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

C :: Data Insertion In Linked List

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

C++ :: Reading Data To A Linked List

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

C++ :: Getting Vowels And Constants From String

Nov 18, 2013

I am working on a code that is suppose to get vowels and consnants from a string. So far i got up to trying to get the vowels from a string. this is what i have so far:

#include <iostream>
#include <string> // includes go into header
using namespace std;
int getword(string word);
int getvowels(string word);

[Code] .....

View 2 Replies View Related

C++ :: Dynamic Data Structures (Linked List)

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

C/C++ :: Reading Data From File Into Linked List

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

C++ :: Possible To Copy All Data From Linked List Into Array

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

C :: Save Data From Global Variable Into Linked List

Jul 6, 2013

I'm trying to run so called student-administration program.I got functions that can read and write student data, but the one saving the data from about 30 students has some problem that I can't figure. (warning: I'm quite new to C programming)so this is the code:..I guess I can't use global variables as function arguments?

Code:

//global variables
static char ReturnName[31];
static char ReturnFirstName[31];
static float ReturnAverage;
}

[code]....

incompatible types when assigning to type 'char[31]' from type 'int'

View 2 Replies View Related

C++ :: Unable To Modify Object Data In Linked List

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

C/C++ :: Dijkstra Algorithm - Reading In Data To A Linked List

Mar 20, 2014

Program to implement Dijkstra's Algorithm. Have Problems storing graph info into linked-list . 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).

#include <cstdio>
using namespace std;
struct ListCell {
ListCell* next;
int vertex;
double weight;
ListCell(int v, double w, ListCell* nxt)

[Code] ....

View 5 Replies View Related

C :: Removing A String - Linked List

Feb 19, 2013

I'm trying to go search through my linked list for a passed string and if it matches, remove it...but obviously link everything back together properly. This is what I have so far but when i pass it to my display function, which is properly working, it goes into an endless loop

Code:
void llRemoveString(LinkedList** ll, char* string) {
LinkedList* newNode = (LinkedList*)malloc(sizeof(LinkedList));
newNode->value = string;
LinkedList* n = *ll;

[Code] ....

View 8 Replies View Related

C :: Parsing Tokens In File Lines Into A Linked List Of Data

Sep 20, 2013

I have been attempting to store mathematical functions in a file by parsing them into a linked list with a variable sized char ** array as my storage device. I have ran into problems with the memory management detail. The program crashes before output is flushed to the console, so printf() wasn't a debugging option. Neither is my actual debugger, since it seems to get a SIGTRAP every time. I have my warnings turned all the way up, but no errors or warnings are appearing. The part I know works is the actual code that opens the file and gets a line from the file. As far as the two functions that implement the linked list, that is most likely where the problem lies. My current attempt is basically to store the size of the dynamic array in the structure and keep resizing it until there are no more tokens. Then I will store the number of elements of the array in the structure and move on to the next node.

Here is my text file I use :

Code:
sqrt( 25 ); pow( 6 ); sin( 2 );
pow( 4 ); tan( pow( 2 ) ); Main.c :

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct file_data

[Code]...

View 7 Replies View Related

C :: How To Sort Data In Linked List And Arrange Them Highest To Lowest

Aug 12, 2013

i am making a program that reads a file from .txt and print them out using linked list. However, i need to sort them from the highest price to lowest price.

Code:

/* my structs */
typedef struct{
Node *head;
Node *tail;
Node *iterator;
int size;
} List;

[Code]...

i know its long but im afraid that i might miss out some things.

View 12 Replies View Related

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 View Related

C++ :: Use Circular Linked List And Data Structures To Store Tasks

Mar 30, 2014

The program use a circular linked list and data structures to store the tasks.

- Every task should include a task name, a name for the person assigned to it, and the deadline for the task.
- Variables should be dynamic and their sizes should be determined at runtime based on the length of user input.
- You should implement the following functions (with appropriate arguments and return types) for your structure: add(), remove(), search(), and list().
- The add()function should add tasks alphabetically by task name. You do not need to implement any file operations.
- The search() function should be able search for a task by the task assignee name or the task name.
- The list() function should print records to the screen in the order they appear in the circular linked list.
- You should successfully deallocate all of the allocated memory before termination of your program.

View 4 Replies View Related

C++ :: Boost Binding - Comparing String Using Strcmp

Jun 5, 2014

I am trying to compare strings (char*) using strcmp but I am having a hard time doing it with boost::bind. It compiles but it crashes when I run it.

I have a std::vector<boost::shared_ptr<DeviceInfo>> cMonitoredDevices and one cCurrentDevices. I used a typedef DeviceContainer for std::vector<boost::shared_ptr<DeviceInfo>>.

DeviceInfo is a simply struct that contains a char[128] Name (and other fields not important for this issue) that I want to use to compare.

So I am trying to find the DeviceInfo (based on Name) that are in cMonitoredDevice but not in cCurrentDevices. My problem is retrieving the Name value for the strcmp. Here is what I have so far

for(DeviceContainer::iterator pDevice = m_cMonitoredDevices.begin();
pDevice != m_cMonitoredDevices.end(); pDevice++) {
if (std::find_if(cCurrentDevices.begin(), cCurrentDevices.end(),
boost::bind(&strcmp, boost::bind(&boost::shared_ptr<DeviceInfo>::value_type::Name, _1),
(*pDevice)->Name) == 0) == m_cMonitoredDevices.end()) {
}
}

View 2 Replies View Related

C :: Insert String At Index In Linked List

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

C :: Inserting String At Index In Linked List

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 linked list...

Code:
typedef struct node {
char* value;
struct node* next;
} LinkedList;
void llAddAtIndex(LinkedList** ll, char* value, int index) {

[Code] .....

View 6 Replies View Related

C# :: Linked List Storing String Values

Apr 8, 2015

I am creating a to-do list application and to store the tasks on the list, I am trying to create a linked list. the code for it so far is as follows:

public class Node //Class for nodes which make up a linked list {
//Declaring the data to be stored in each node and next variable to point to the next node
public string title;
public string description;
public string priority;
public string finish;
public string complete;

[Code] ....

The problem with this arises when I try to create a new node from another class like so:

createForm create = new createForm(); //Creates an object reference to createForm
create.ShowDialog(); //Shows the createTask form for creating a new task
//Declares variables and stores the return value of methods in createForm
string _title = create.getTitle;

[Code] ....

The variables _title etc.. all store values from text boxes as string. However, the code creating the object says the the variables cannot be implicitly converted from type 'string' to 'int'. Why this error is happening??

View 3 Replies View Related

C :: Creating Linked List Of Students With Individual Data Read From A File

Aug 27, 2014

In the program I'm writing, I'm creating a linked list of students with individual data read from a file. At the moment, I have written two functions to accomplish this; one that creates a student node and fills it from a line file, and a second that calls on the first to create a linked list. It seems to work fine except for one thing; It seems that EOF is being reached first, but the function continues on anyways? Here is my code so far...

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student
// Declaring student structure globally.

[Code] .....

And here is what the input file would look like...

Thui Bhu, 100, 90, 80, 100, 89, 99, 88
Ariana B. Smith, 90, 90, 100, 100, 99, 100, 95
Emily Gonzales, 100, 90, 100, 70, 78, 78, 80
Jennifer L, 80, 90, 90, 100, 89, 99, 85
Maria Jones, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 38, 62, 65, 60, 50
Escobar Morris, 83, 77, 88, 76, 79, 72, 76
Anne Latner, 80, 80, 85, 95, 90, 95, 98
John Doe, 45, 87, 88, 89, 67, 96, 79

And here is what the output is...

EOF

EOF in create_record

Thui Bhu: 100 90 80 100 89 99 88
Ariana B. Smith: 90 90 100 100 99 100 95
Emily Gonzales: 100 90 100 70 78 78 80
Jennifer L: 80 90 90 100 89 99 85
Maria Jones: 65 72 77 68 62 70 65
Bill Gates: 60 54 38 62 65 60 50
Escobar Morris: 83 77 88 76 79 72 76
Anne Latner: 80 80 85 95 90 95 98
John Doe: 45 87 88 89 67 96 79
Press any key to continue . . .

View 2 Replies View Related

C :: Command Line And Converts String From File Into A Linked List

Jul 10, 2013

My program takes in an input file from the command line and converts the string from the file into a linked list and then depending on the command it will manipulate the string to either reverse the list, print the list, or take a character out...I'm having trouble taking a character out, my code compiles fine but doesn't change the string at all

Code:

#include <stdio.h>
#include <stdlib.h>
#define SIZE 1024

[Code]....

View 4 Replies View Related

C++ :: Creating A Linked List Of Common Elements From Two Other Linked Lists

Apr 29, 2013

I'm trying to write a function that takes two linked lists and creates a third one with only the common elements.

It assumes the first list (the caller) has no dups, but it doesn't seem to be working. The program doesn't crash, it just hangs when it is supposed to display L3 (the third list)..everything else runs and is displayed fine.

template <typename T>
LList <T> LList <T>:: common (LList <T> &B)//common fct
{
Node <T> *hunter1 = Head;

[Code]......

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved