C++ :: Read Coordinates From Text File Into Double Linked List

Mar 25, 2014

I am doing c++ program to read coordinates from text file into double linked list. Everything seems to work perfectly but it stores only 298 items in linked list. Im not sure if my code is wrong or I missed something. On the debugger length of list is over a 1000 but like I said it print outs only 298.

View 2 Replies


ADVERTISEMENT

C :: Program To Read In A Tab Deliminated Text File Of Xyz Coordinates

Nov 14, 2013

I have been working on a program to read in a tab deliminated text file of xyz coordinates of atoms/particles and store the values in three seperate arrays. This is my code so far:

Code:

#include<stdio.h>
#include<stdlib.h>
void fileinput(FILE *ifp) {
int N, column, atom;
int c;
column = 1;

[Code]...

Supposedly this should assign the values in the text file to the cooresponding arrays but when I run the code on a simple test file all I get is:

Code:

$ ./input.o -i ./test.txt
Atom one coodinates x 0.000000, y 0.000000, and z 0.000000 Where test.txt is: Code: 1.0000 2.000 1.5
3.0000 5.000 1.4
4.0000 3.000 1.3

View 1 Replies View Related

C :: Unable To Read TXT File Into A Linked List

Sep 15, 2014

I've been trying to read a .txt into a linked list in the attached code. I'm running into problems, specifically I'm getting errors on line 41 (curr->word=charTemp. I'm trying to set the word array equal to the charTemp array. I've tried strcpy with no luck .

Code:

#include <stdio.h>#include <stdlib.h>
#include <string.h>
//Struct for linked list
typedef struct node {
char word[25];
struct node *next;
} node;

[Code]...

View 2 Replies View Related

C++ ::  Read From File And Insert Into Linked List

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

C :: Reading A Text File Into Linked List

Oct 15, 2013

I am trying to read in a text file and add strings from it word by word into a Linked List. I'm fairly new at C and don't quite understand pointers. I've had a few different errors just messing around with it, but now I'm getting an infinite loop within my main program.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

struct listNode { /* self-referential structure */
char data[50];
struct listNode *nextPtr;

[Code] ....

When I run my full code, it prints 12345ooooooooooooooooooooooo...etc. In my test file the first word is "Hello" so that's where the infinite 'o's come from. If the outer loop is the one that is infinite, then wouldn't the second while loop also execute more than once? What I mean is, why is the second print statement the only one that repeats itself?

View 5 Replies View Related

C/C++ :: Reading File From Text To Linked List

Dec 1, 2014

I have to initialize my stack (done by linked list) and I have a txt file for that. It looks like

123 Mike Smith 3.5 BA
124 John Weasly 2.9 CD

Here is what I have done so far:

However, I cannot reach any result.

Let me update:

123 Mike Smith 3.5 BA
124 John Weasly 2.9 CD

Here is what I have done so far:

struct Record{ //struct
float number;
char name[10];
char surname[10];
float GPA;
char mark[SIZE];
Record *next;
};

[Code]...

View 1 Replies View Related

C :: Double Linked List

Jan 2, 2014

I'm having a small issue here with my linked list.I built a linked list with strings and it worked perfectly.Now since i'm using strtok() to separate the string.for now here's what i've got:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct dict_word *word;
typedef struct node *Node;
typedef struct double_linked_list *DLL;
}

[code]....

View 1 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++ :: Double Linked List Implementation

Dec 27, 2013

I'm trying to set up a simple implementation of a double linked list... But I seem to some mistakes.

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
#define ValueType int
struct vertex {

[Code] ....

I get 'Test: root exists' printed out, but not the loop through my linked list.

View 11 Replies View Related

C++ :: Insert Into Certain Position In Double Linked List?

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

C/C++ :: Implementing Stack Using A Double Linked List

May 12, 2014

So im trying to write a code that will take data in from a user and when that user enters specific character then i want to pop the top of the stack and place that node on a new stack. Then if the user enters a different specific character then i want to place what was just popped off the stack back on to the original stack. Anyways i'm just testing what i have without all the complicated stuff with the specific characters, but i get an error and i'm not not well versed in exception handling. So this is what i have so far. the push seems to work well but the pop seems to be giving me problems.

Stack::Stack(){
top = NULL;
bottom = NULL;
}
//method to push a line of text onto the stack
void Stack::push(string data)

[Code] .....

View 4 Replies View Related

C++ :: Double Linked List - Node Undeclared

Apr 2, 2013

I am developing a double linked list in C ( development environment ) is QT with mingw32 4.7 gcc / g++ compiler , in the header file I have defined struct as follows :

Code:
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <stdlib.h>
#include <sys/stat.h>
#include <signal.h>
#ifndef NULL

[Code] ....

When compiling I am getting the following error : 'NODE' undeclared (first use in this function)

and

each undeclared identifier is reported only once for each function it appears in

I have also attached the screen shot from the QT IDE

look's like the compiler is not able to pick up the definition of NODE structure , same happens in Netbeans IDE , interesting thing is if change the source file from c to cpp the error goes away .

View 3 Replies View Related

C/C++ :: Reading X / Y Coordinates In Text File

Apr 7, 2014

I need to read x,y coordinates in text file using c++. The name of file is input.txt which is,

x      y
232.1,753.7
100.5,981.6
96.2,992.9
148.7,953.2
197.2,999.3
249.9,998.6
261.7,975.9
262.4,905.8
334.9,980.8
371.6,979.4
396.7,996.3
405.1,995
565.5,766
459.4,988.5
474.4,994.6
594.6,996.8
604,987.3
612.8,877.3
664.1,992.6

#include <iostream>
#include <fstream>
using namespace std  
struct monsters_struct {
int x, y;

[Code] ....

View 1 Replies View Related

C/C++ :: Unable To Delete A Node In Double Linked List

Aug 22, 2014

I am trying this without a head/start pointer which would generally hold the address of first node. I have 3 nodes here from which I am trying to delete last node, but its not happening. I might be wrong in my logic and this is my first linked list program.

#include <stdio.h>
#include <stdlib.h>  
struct dll{
            struct dll *prev;
            int data;
            struct dll *next;

[Code] ....

output::::

add of p1::0x9605008 add of p2::0x9605018 add of p3::0x9605028 add of p1->prev::(nil) add of p1->next::0x9605018 add of p2->prev::0x9605008 add of p2->next::0x9605028 add of p3->prev::0x9605018 add of p3->next::(nil)

no of nodes 3

enter the addresss of node to delete it
0x9605028

after deletion attempted

add of p1::0x9605028 add of p2::0x9605018 add of p3::0x9605028 add of p1->prev::0x9605018 add of p1->next::(nil) add of p2->prev::0x9605008 add of p2->next::0x9605028 add of p3->prev::0x9605018 add of p3->next::(nil)

no of nodes 3

In this example i am trying to delete the node 3 which is p3, by deleting its address 0x9605028. But after deletion the node count is still 3 and addresses are like unexpected!

View 1 Replies View Related

C/C++ :: Print Name And Ages Forward Then Reverse Using Double Linked List

Apr 28, 2015

I have to write a c program that will allow the user to enter names with ages. The name will be no longer than 40 characters. The name and age should be stored in a node of a doubly linked list. I cant use global data. I need to use 3 subroutines. the first one needs to enter the data and pass the head and tail pointers to the subroutine. the next subroutine needs to print the names and ages to the screen and file output.txt from first to last. the last subroutine needs to print out names and ages to the screen and file output.txt from the last to first.

Im getting several errors when i try to run this program. The first subroutine to get the data from the user and build the double linked list. but i seem to be having issues.

#include <stdio.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int entry(char [][41], int []); // subroutine used for data entry //
void printit(char [][41], int [], int); // subroutine used for data printing //
void reverseprintit(char [][41], int [], int); // subroutine used for reverse data printing //

[Code] .....

View 11 Replies View Related

C/C++ :: Doubly Linked List Versus Double Ended Queue

Jun 27, 2014

A while ago i was asked to write a program for a class that used a "Double ended queue with a current-position marker."

An example of some of the functions that i created are:

boolean atFirst() // Returns true if first element is current. Pre: !isEmpty().
boolean atLast() // Returns true if last element is current. Pre: !isEmpty().
void makeEmpty() // Sets this List to the empty state. Post: isEmpty().
void moveFirst() // Sets current marker to first element.
void movePrev() // Moves current marker one step toward first element.
void moveNext() // Moves current marker one step toward last element.
void insertBeforeFirst(int data) // Inserts new element before first element.

My question is whether a double ended queue with pointer is the same thing as a "doubly linked list" in this case. The terminology is throwing me of a little. If the two concepts are different, how is a doubly linked list different?

View 2 Replies View Related

C++ :: Creating A Class That Would Implement Concept Of Double Linked List Like A Queue

Jun 15, 2013

Well, basically, what I've been doing was creating a class that would implement the concept of Double Linked List, but that would behave like a queue ( the STL implementation is deque, or Double Ended Queue ).

The problem occured when I have been trying to generalize the class using templates. I mean, why use only integers ? Why not double or char or what not ?

Worked perfectly before including all the template stuff..

// Source.cpp <=> Main.cpp
#include <iostream>
#include "DList.h"
using namespace std;
int main(void) {
DList<int> *list;
list = new DList<int>();

[Code] .....

The errors returned by the compiler:

Error1error C2955: 'Node' : use of class template requires template argument listc:usersjumperdesktopc++ otherdouble linked listdouble linked listdlist.h6
Error2error C2955: 'Node' : use of class template requires template argument listc:usersjumperdesktopc++ otherdouble linked listdouble linked listdlist.h6

View 6 Replies View Related

C/C++ :: Linked List To Simulate Text Editor

Mar 10, 2015

I am trying to make a text editor in C++ that uses Linked Lists as the main driving force. I need to make a program that can add a line of text at a certain point, delete a certain line of text, print the entire text, and quit and save the text to the original text file inputted from the shell script. My problems are with the cpp file, and the linked list files. My remove function is not what I need it to be I know that. I also know that there are some problems with my cpp file myEditor. My code is below.

#include <sstream>
#include "linkylist.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[]) {
//node* head = new node;

[Code] ....

View 6 Replies View Related

Visual C++ :: Doubly Linked List And Basic Text Editor

Sep 23, 2014

I'm supposed to make a basic text editor using a doubly linked list, I have pretty much written most of it but keep coming across several problems. In certain places,all marked in the code, I get the error "expected a declaration" ive looked online and nothing ive found works. And secondly I also get the error" declaration has no storage class or type specifier" but i havent been able to find anything that works either.

Code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <assert.h>
#include <string>

[Code] ....

View 6 Replies View Related

C++ :: Mouse Input Coordinates Not Being Read

Jan 14, 2015

Essentially the problem is that when I click the mouse, the program doesn't seem to record the coordinates. So the if statements are never executed. The problem could also be with the if statements, I'm not sure.

One thing I noticed was that when the do while loop is running and the left mouse button is not pressed then X and Y of dwMousePosition are both 0. But then if I press the left mouse button then the coordinates become x = 1 and y = 0.

NOTE I'm on Windows 7, 64 bit, using Visual Studio Express 2013 for Windows Desktop

#include <iostream>
#include <windows.h>
#include <string>
#include <new>
#include <stdio.h>
using namespace std;
INPUT_RECORD ir[128];
DWORD nRead;

[Code] .....

View 1 Replies View Related

C++ :: Getline - Get Text File And Read Only First 100 Lines Of Text Content

May 31, 2013

I am trying to get text file and read only first 100 lines of the text content using c/c++. how can i do it?

is it something like string line;
getline(stream,line);

??

View 7 Replies View Related

Visual C++ :: Mouse Input Coordinates Not Being Read

Jan 14, 2015

When I click the mouse, the program doesn't seem to record the coordinates. So the if statements are never executed. One thing I noticed was that when the do while loop is running and the left mouse button is not pressed then X and Y of dwMousePosition are both 0. But then if I press the left mouse button then the coordinates become x = 1 and y = 0.

I am on Windows 7, 64 bit, using Visual Studio Express 2013 for Windows Desktop

Code:
#include <iostream>
#include <windows.h>
#include <string>
#include <new>
#include <stdio.h>
using namespace std;
INPUT_RECORD ir[128];

[Code] ....

View 1 Replies View Related

C++ :: List Of Latitude And Longitude Coordinates - Sorting Algorithm

Jul 4, 2012

I have a list of latitude and longitude coordinates which are supposed to trace the outline of a city. Somehow they got scrambled so that they are now out of order. I'd like to write a program to arrange them such that one could follow from one coordinate to the next and trace the perimeter. However, I've run out of ideas for algorithms. What I did so far was a simple search for the nearest coordinate, starting from the first coordinate pair in the array. This produced local regions which worked rather well, but globally there were large jumps as the algorithm ran out of nearby coordinates and was forced to jump across the map.

Is there already a developed algorithm to perform this function?

View 1 Replies View Related

C++ :: Reading TXT File Into A Linked List

Nov 19, 2013

Code:
void loadData(fstream& fin, nodePtr head){
if (fin.eof()) {
return ;
}
else

[Code] .....

This is my function and it is not working.

View 7 Replies View Related

C++ :: Reading From A TXT File To A Linked List

Nov 17, 2013

Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include "contacts.h"

using namespace std;

[Code] ....

Lines 29-32 I have a good feeling very wrong. Now I have never learned how to do this and my book covers nothing over this. I just took my final in C++ so this is not homework. I am trying to get better before Data Structures start next month.

View 3 Replies View Related

C/C++ :: Linked List - Method To Add To File

Feb 21, 2013

I am trying to write a program which involves linked list. i have to create a method called add_aa( str ). I am reading from a text file. in the text file it just contains the values for str. what I am trying to do is create the method add_aa( str ) and add what corresponds to str from the file. here is what the output should look like. and what i have is very basic. here is what i have

inline void LList:: add_aa(const string _str) {
    cout << " p = " << std::hex << p << std::dec << '
'; 
}

I'm thinking using a for statement, but how to incorporate it

Attached Images : sample.JPG (35.2 KB)

View 1 Replies View Related







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