C++ :: Can't Get Specifically Ordered List To Print Properly

Dec 21, 2014

I'm writing a program where the user inputs a number of rows, and that many rows of @ symbols are printed, where the first row has the same number of columns as rows, and each next row decrements the number of columns by 1. It prints out a totally wrong output and whatever I try it won't print the right thing- currently when I input 4 it prints out 5 @ symbols on the first row, and then 3 on all the other rows.

Code:

#include <iostream>
using namespace std;
int main ( ) {
int rows;
cout << "How many rows? ";
cin >> rows;

[Code] .....

View 2 Replies


ADVERTISEMENT

C++ :: Searching An Ordered List

Oct 3, 2013

Make an ordered array. Put a bunch of random numbers into it. Do 20 linear searches and 20 binary searches of that array. (Code for linear search and binary search are found in the book.)Print out how many elements were checked before the item is found

I'm not looking for answers as it is homework. However I don't understand what I'm doing. This course is being held online(no other options) and that's not how I learn so I'm struggling. From my understanding I have to make a templated ordered array (which I don't understand at all) and then do searches (which I also don't understand).

View 1 Replies View Related

C++ :: Writing Delete Algorithm In Ordered Linked List

Oct 19, 2013

I am trying to write a delete algorithm for an ordered linked list. Search and traverse I think I have down but delete is giving me fits. It crashes every time.

I have a private pointer to a ListNode strcuture called head in my TestLL class. The ListNode structure contains int Key, double dataValue, and ListNode *next. The function returns true if the node to delete was found and deleted or false if it was not found.

Code:
bool TestLL::Delete(int Key) {
ListNode *back = NULL, *temp = head;
//Search for the node to delete
while((temp != NULL) && (key != temp -> key))

[Code] .....

View 4 Replies View Related

C++ :: Print Function Does Not Work Properly

May 21, 2013

This is my code for submitting students but when i use search function the course member is empty

Code: #include "windows.h"
#include "iostream"
#include <io.h>
#include <sstream>
#include <conio.h>
#include <stdlib.h>
#include <iostream>
#define SIZE 5
using std::cout;
using std::cin;
using namespace std;
int menu();

[code].....

View 11 Replies View Related

C :: Delete Each Element In The List Which Is Same - Function Does Not Work Properly

Jan 18, 2014

Code:

struct lista* del(struct lista* p, char* path1) {
char model[MAX2];
int len;
char ch;
printf("Type model.

[Code] ..... t

This function should delete each element in the list which is the same as this one typed by user. There are no errors, but function doesn't work. It deletes something, but not this element which should.

View 5 Replies View Related

C++ :: Positioning SFML Text Specifically?

Sep 20, 2013

I am trying to position and sf::Text relatively to another sf::Text. Not over, or beneath or anything like that, but after- like so:

theTexts.push_back(UnitOfText(Text(outputstring,defaultFont, 15),theColor));
int i = (theTexts.size() - 1);
std::cout << i;
sf::FloatRect textRect ( theTexts[i].theText.getLocalBounds() );
theTexts[i].theText.setOrigin (textRect.width / 2, textRect.height / 2);
if(theTexts.size() > 1)
{
theTexts[i].theText.setPosition(theTexts[i - 1].theText.getLocalBounds().left,theTexts[i - 1].theText.getLocalBounds().top);
}

View 4 Replies View Related

C/C++ :: How To Deserialize Save Game Data (specifically Skyrim)

Jul 29, 2014

I'm working on my first own project which is to collect some info from a save game file and then parse it to a website. Skyrim uses a .ess file extension, which to my knowledge is a binary file. I know how to open a file for reading but how to extract the info I need from there. Do all games use a standardized serialization or can the format of this file be anything?

If reading the binary file turns out to be too difficult, would it be possible to hook the game and retrieve info that way? If so, where would you recommend to start learning that stuff?

View 1 Replies View Related

C++ :: Templates And Ordered Linked Lists

Feb 10, 2014

A static method named readFromFile that takes a C-string as the first parameter, and an orderedLinkedList<MemberDO> object as the second parameter. The first argument is the filename that contains data for existing members. This method should read the data for each individual member from the input file (one line of data per member), create a new MemberDO object, and insert this object into the linked list specified in the second argument.

How do I take the second parameter in, do I need to create the Linked List first? Here is the code I have so far

#include<iostream>
#include<string>
#include <fstream>
using namespace std;

class MemberDO {

[Code] ....

What to do with the readFromFile static method?

View 1 Replies View Related

C/C++ :: Make Circular List And Print It

Apr 28, 2015

I have this program. I am trying to do this Circular List but i think something going wrong. The first of all is the list.The second is if my code for delete and select function are correct and the third i would like my program getting a "n" number of names and then make the circural list then print it and then when i select a number delete every node until give us the only one left.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 10
#define NUM_PER_LINE 6
typedef struct node {
char name[SIZE];
struct node * next;

[Code] .....

View 1 Replies View Related

C++ :: Print Linked List But As A Vector Of Char

Aug 26, 2013

I was assigned to print a linked list but as a vector of char (I cannot use the normal string type) , this is what I have:

char* List::asString(){
Node* ite = new Node();
ite= first;//ite is like an iterator of the list
for(int i=0; i<sizeOfList; ++i){//sizeOfList is the total of node of the list

[Code] ....

But when I print that, I get a bunch of weird symbols...

View 7 Replies View Related

C/C++ :: Compare Two Arrays And Print Out A List Of All Songs Without Repeating

Mar 11, 2014

I have two arrays:

const char *mymp3list[15] = { "Song 1", "Song 2", "Song 3", "Song 4", "Song 5", "Song 6", "Song 7", "Song 8", "Song 9", "Song 10", "Song 11", "Song 12", "Song 13", "Song 14", "Song 15" };
const char *myFriendsmp3list[20] = { "Song 1", "Song 2", "Song 3", "Song 4", "Song 5", "Song 6", "Song 7", "Song 8", "Song 9", "Song 10", "Song 11", "Song 12", "Song 13", "Song 14", "Song 15", "Song 16", "Song 17", "Song 18", "Song 19", "Song 20"};

And I want to compare the two arrays and print out a list of all the "songs" without repeating any.

I've figured out how to print the just the duplicates using:

for (int count = 0; count < SIZE1; count++){
for (int i = 0; i < SIZE2; i++){
if (mysonglist[count] == friendsonglist[i])
cout << mysonglist[count] << "";
}
}

But I'm stumped on how to print a full list containing no duplicates.

View 4 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++ :: Read List Of Numbers From A File And Then Print Out In Reverse Order

Apr 6, 2013

1. Construct a class diagram that can be used to represent food items. A type of food can be classified as basic or prepared. Basic food items can be further classified as meat, fruit, veg or Grain. The services provide by the class should be the ability to enter data for new food, to change data for food and to display existing data about food.

using this class definition write a main program to include a simple menu that offers the following choices:

1. Add food
2. Modify Food
3. Delete Food
4. Exit this menu

2. Read a list of numbers from a file and then print them out in reverse order. State whether the list is palindromic or not.

View 2 Replies View Related

Visual C++ :: Program To Print List Using Iterator And Operator Overloading

Nov 19, 2014

I'm trying to use the given Iterators to overload my = operator to print my list to screen. I keep getting Link2019 error though and have narrowed the problem down to my print operator. I'm wondering if it has anything to do with the fact that my operator is in private part of class? I'm new to this concept.

Code:
#include "List.h"
// methods for Node all
//ME
Node::Node( const string &s, Node * p, Node * z) : word( s ), next( p ), prev(z)//constructor {
word = s; // init. word data with a copy of s
next = p; // next pointer points to p

[Code] .....

View 1 Replies View Related

C++ :: Date Class - List Major Holidays And Print Calendar For Given Year

Mar 20, 2013

I'm trying to implement a Date class to create a simple application for " Major U.S. holidays calendar System ", that provides a list of major holidays for a given year AND prints the calendar for the given year either online or write to a file. I need to finish up the class date.h, which is

#ifndef DATE_H
#define DATE_H
#include <string>
#include <iostream>
using namespace std;
string Month[]={"" , "January", "Febraury", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"};

[Code] .....

View 1 Replies View Related

C++ :: Convert List Of Binary Numbers From A File Into Decimal And Print To Screen

Sep 23, 2014

I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:

3
10110101
11111111
10101010

The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.

I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....

View 4 Replies View Related

C++ :: Implementing Recursive Function To Print Linked List In Reverse Order

Nov 29, 2014

Implement a recursive function named void printBack(DoublyLinkedNode<T>* node) for the class DoublyLinkedCircularList which will print out the elements in the list from back to front. The function is initially called with the first node in the list. You may not make use of the previous(prev) links

This is my solution where I got 2 out of a possible 3 marks:

template<class T>
void DoublyLinkedCircularList<T> :: printBack(DoublyLinkedNode<T>* node) {
if(node->next == NULL) //Correct- 1 mark
return 0;
else
printBack(node->next); //Correct - 1 mark
cout << current-> element << " ";
}

View 3 Replies View Related

C/C++ :: Print Single Linked List Backward With Functions / Classes - Error Message Regarding Header Files

Oct 11, 2014

I'm trying to print a single linked list backward with functions/classes. I have created the main file and 3 header files. But I'm getting an error on one of the header files, linkedListIterator after adding #include "linkedListType.h". It says that "linkedLlistType.h" is calling itself. And when I try to run it, I get an error of "too many header files." I have tried changing the headers many times, but nothing seems to work.

.cpp file:

/*(Printing a single linked list backward) Include the functions reversePrint and recursiveReversePrint, as discussed in this chapter, in the class linkedListType. Also, write a program function to print a (single) linked list backward. (Use either the class unorderedLinkedList or the class orderedLinkedList to test your function.)*/

#include "linkedListType.h"
#include "orderedLinkedList.h"
#include "linkedListIterator.h"
#include <iostream>
using namespace std;
struct nodeType

[Code] ....

header files:
[URL] .... (error in this header file)
[URL] ....

View 9 Replies View Related

C :: Cannot Get Strstr To Work Properly

Aug 26, 2014

I am unable to get the string seaching function to work. it always says "Nothing found" I am stumped.

Code:

#include <stdio.h>
#include <string.h>
char tracks[][80] = {
"I left my Heart at Harvard Medical School",
"Newark, Newark, You suck balls",
"Dancing with a dork",
"From Here to maternity",
"The Girl from Iwo Jima",

[Code]....

View 3 Replies View Related

C :: String Not Validating Properly?

Mar 5, 2013

1. In main() in the while loop entering 'q' does not exit.

2. in the isbnValidation function. The size check for minimum length words will work, but the check for "Invalid ISBN character" doesn't.

3. Every ISBN entered returns as valid. The formula is supposed to multiply the first digit by 10, next by 9 etc (skipping all the dashes) and add up to a weighted total which if valid will divide evenly by 11.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ISBNMIN 10
#define ISBNMAX 14

[Code].....

View 4 Replies View Related

C++ :: File Is Not Reading Properly?

Mar 30, 2013

I have a file which I am unable to read properly. This is binary file so my code is"

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

[Code]....

the file to read can be download from this link :

[URL]

The first content of file should be 1 I am missing few content from the begining

View 2 Replies View Related

C++ :: How To Properly Iterate Over A Container

Oct 31, 2013

so i have a container called Source that is of type std::map<std::string, std::vector<std::string>> but when I try to print it with this function:

void Lexer::PrintSource()
{
for(auto Iterator = this->Source.begin(); Iterator != this->Source.end(); Iterator++)
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
cout<< *SubIterator << endl;
}

i get these errors:

Lexer.cpp: In member function 'void Lexer::PrintSource()':
Lexer.cpp:29:42: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'begin'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^
Lexer.cpp:29:76: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'end'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^

View 6 Replies View Related

C++ :: Variable Not Functioning Properly

Sep 29, 2014

#include <iostream>
using namespace std;
int main()
{

[Code]...

For some reason, I get the cout of

321
1

Because of the a++, shouldn't it be

321
2

The second example is what the cout needs to be.

View 1 Replies View Related

C++ :: Properly Exiting A Program

Sep 2, 2013

If I were to exit a program, is it okay if I fail to properly destroy whatever structures were allocated?

For instance, if I do this with SDL, there might be obvious consequences like a dead window perhaps. But if I do this with a POD structure, is it okay?

Also, I realize RAII is supposed to fix parts of this but it's not perfect when environments are suddenly cut off with something like exit(1/0);

View 2 Replies View Related

C# :: Parsing XML File Properly

Apr 11, 2014

I'm parsing an xml file full of payslips and using the data in another application. I've got it all working but I suspect it isn't the most elegant piece of code. I run through the xml file finding a series of "Text" attributes/elements" and then I run through it again finding a series of "Field" attributes/elements, Here is a sample of the code:

For getting the "Text" fields :

XNamespace ns = "urn:crystal-reports:schemas:report-detail";

//
// Get all the Text attributes & Elements
//
foreach (XElement xtxt in xdoc.Descendants(ns + "Text"))

[Code]...

This works fine, I extract all the data I'm interested in and go to do my thing with it. However I really need to know when each record ends and I was doing that by looking for "Text24" in the text fields and "EeRef2" in the field fields, which wasn't very elegant in the first place. Then a "Text16" was added to end of each record which was fine I could just look for "Text16" but now it's apparent that "Text16" isn't always there. I've got it all working for now but I'd prefer to process one record at a time i.e. extract all the "Text" & "Field" values for one record, do whatever I need to do with it, update the xml file to indicate this progress ( if possible ) and then move on to the next record. I've attached a sample of the xml but basically is has the following structure :

<Details>
<Section>
<Text></Text>
"
<Field></Field>

[Code]...

So a record is everything between the first <Details> and the last </Details> with two <Details> and two </Details> in between.

View 2 Replies View Related

C/C++ :: Threading / How To Invoke It Properly

Jun 12, 2012

I'm using MS' optimizing compiler CL 13.10 (one from VCToolkit 2003) along with WinAPI threading functions and is being compiled as a C console program.

I was wondering how to implement threading in a production setting? I've seen and tried various examples, but they all show basically the same thing - startup in main, run their function, clean up, and then the program exits.

I don't know the proper terminology, but I was looking for two maybe three functions to run simultaneously with a loop in main. I tried a small test program and was wondering if it's setup correctly.

A structure is used as the argument for each function.

int running = 1; // global variable  
DWORD WINAPI function_1(LPVOID);
DWORD WINAPI function_2(LPVOID);   
main() {  
   HANDLE hndThreads[2];
   DWORD threadIDs[2];

[code].....

Right now, function_2 is just a copy of function_1's definition. Everything *appears* to do what I want, but is it setup correctly?

View 2 Replies View Related







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