C++ :: Not Marking That The Queue Is Full

Apr 11, 2013

Why is this code not marking that the queue is full.. I'm just including my Add function that verifies if they want to add another number to the queue. The isFull function works fine, have used it on other programs.

template <class T> //Template currSize function
int Queue<T> :: currSize ()
{
return (rear - front + arraylength) % arraylength; //

[Code].....

The output goes all the way down to 1 spot left, lets the user enter the last element. Then it asks if they want to add another.. At this point, when they hit Y, it lets them add it and it says there are 5 spots left!

View 8 Replies


ADVERTISEMENT

C++ :: Increase Sizes Of Queue In A Vector Of Queues And Find Shortest Queue

Feb 20, 2013

I have a paradigm in a loop of queues of a vector,if a condition is true,increase sizes of the queue of that particular queue in the loop of queues, if condition is false, the queuesize is left as such in loop of queues. After this operation i need to search the queue sizes of all queues and enqueue in the shortest queue.

I want to do something like the code given below

#include <vector>
#include <queue>
int min_index = 0;
std::vector<std::queue<int> > q
std::size_t size = q.size();

[Code] ....

How to implement this logic?

will q[i].size=q[i].size+5 increase the queuesize by 5 for the ith queue?

View 12 Replies View Related

C :: Reading And Accepting Full Name

Feb 6, 2013

I am having trouble in reading my full name in just a single variable and some kind of authentication. this is my code by the way.

Code:

#include <stdio.h>
int main(void)
{
char NAME_MINE1[40];

void clrscr();
}

[code]....

if i enter my full name i will be able to go on to the next statement/command but when i put on some name (which is not mine) i will automatically get an error and exit the program.If i type "Qwerty You Tube" EXACTLY and not just the first string before the whitespace i will be able to proceed but when i enter "Qwerty Tube You" or "Qazse Qop Queen" i will get an error and the program will exit.

View 6 Replies View Related

C++ :: Get Full Time Without Seconds

Jun 21, 2013

I have a code to check the last time modification of a file using "gmtime". Is it possible to remove the seconds in the result?

Here is my code:

struct tm* clock;// create a time structure
struct stat attrib;// create a file attribute structure
stat("test.txt", &attrib);// get the attributes of afile.txt
clock = gmtime(&(attrib.st_mtime));// Get the last modified time and put it into the time structure

View 6 Replies View Related

C++ :: Getting Full Sentence To Input?

Oct 29, 2013

#include <iostream>
#include <string>
#include <istream>

[Code]....

It seems like my program doesnt want to take in a sentence, only the first word i type in

View 1 Replies View Related

C++ :: Get Full Path Of File?

Nov 26, 2013

I wanted to make my program read the file "input.txt". I did it successfully, but now I want to get the full path of the file "input.txt". Is there any way to do it?

My output should be :

FILE *file;
std::string fullFileName;
file = fopen("input.txt", "rb");
if(file != NULL)
{
// getfullfilename(file, fullFileName);
// std::cout << fullFileName.c_str() << std::endl;
}

View 5 Replies View Related

C++ ::  Getting A Full Path By Using Text File Name

Jan 16, 2014

How to get a full path of a directory only using a text file name? (Btw i am using visual studio not windows)...

View 9 Replies View Related

C/C++ :: How To Store Full Name In Two-dimensional Array

Nov 3, 2014

I'm trying to design a C program that ask the users to type their full name (seperate by a space), and store this name in a two dimensional array. I just want to test if I did it correctly, so i just entered one name and give it a try.

char name[50][2];
printf("enter the neame");
scanf("%s%s",&name[0][0],&name[0][1]);
printf("%s",name);
return 0;

but the program will not print the expected result.

View 4 Replies View Related

C++ :: Create A Pointer To A Full Text Line

Jun 3, 2013

It's really simple to say to a pointer to point to a sigle character or a single number.

Code: int *ptr;
int a = 5;
cout << *ptr << endl;

But I want for example a pointer to change a whole text line. My idea is that the user enters which language he speaks.

Code: cout << "English" << endl;
cout << "Swedish" << endl;

But I don't know how to this. I could have done this without pointers with if statments but I want to do it with pointers because it were a exercise to do.

View 3 Replies View Related

C :: Reading Full Sentence From Stdin And FILE

Sep 12, 2014

I thought maybe there was something in C that could read full sentences from stdin

Code:
scanf("%100[^
]s", string);

But that's not working for me. so i came up with my own function and its not giving me the results i want. here is the function including the call from main:

Code:
/* * * * * * * * * * * * * *
* FROM MAIN *
* * * * * * * * * * * * * */
printf("
Adding a new part...
");
printf("Enter part name: ");
get_string(new_part.pname);

[Code] .....

/* * * * * * * * * * * * * * * * * * * * * * *
* UNDESIRED OUTPUT *
* * * * * * * * * * * * * * * * * * * * * * */
8newpart

Where is the eight coming from? i thought fpurge clear the buffer. Also, I'm trying to add spaces in between words... i thought maybe putting within the while loop but outside of the if statement string[length +1] = '' would work, but it doesn't. so i put it outside of the loop but that i knew that wouldnt work either.

Problem #2 is reading from a file.. so far i have the following code which reads everything perfectly except the .txt file has a new line character at the end and i think its reading it:

Code:
/* * * * * * * * * * * * * * * * *
* READS FROM FILE *
* * * * * * * * * * * * * * * * */

if(read_in != NULL)
{
while ((fgets(read_string, MAX_PARTS ,read_in) != NULL) && (array_position < MAX_PARTS))

[Code] ....

0 in stock i want it to stop after reading the ball bearings line. a lot of issues for one post, but all related to reading inputs so i put it all on one.

View 2 Replies View Related

C++ :: Program To Emulate Full Screen Console

Dec 5, 2013

So, I'm making a program in C++ that emulates a full screen console... I used SetCurrentConsoleFontEx to set the font to 12x16 but it sucks...

Anyway, I read here: [URL] .... that also the console font can be changed, but I can't make it work! How can i set the font to Lucida Console? This is the function I use to change font size:

void setFontSize(int x, int y) {
PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx = new CONSOLE_FONT_INFOEX();
lpConsoleCurrentFontEx->cbSize = sizeof(CONSOLE_FONT_INFOEX);
GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, lpConsoleCurrentFontEx);
lpConsoleCurrentFontEx->dwFontSize.X = x;
lpConsoleCurrentFontEx->dwFontSize.Y = y;
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, lpConsoleCurrentFontEx);
}

View 2 Replies View Related

C++ :: Build Full Computer Algebra System?

Apr 1, 2013

Im trying to build a full computer algebra system in c++

View 1 Replies View Related

C/C++ :: Full Menu Not Shown When Running Program

Mar 4, 2014

The program is not showing my full menu just the 0 Exit and the last line of text. This is the full main source file (not implementation file or header file).

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
struct menuItem{
string itemDesc;
double price;
int menuType;

[Code] .....

View 3 Replies View Related

Visual C++ :: Enter First And Surname And Then Display Full Name

Sep 21, 2012

I'am new to C++, program is : enter first and surname and then display the full name:

code below:

// Enter first and surname and then display the full name.
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

[Code] ....

View 10 Replies View Related

C++ :: Convert Full Word To Uppercase If It Is Lowercase In A String?

Feb 28, 2014

The problem I am facing is that I have to output the C++ input file and display every line of code in the output, except in the output I have to convert every if, else, and while as IF, ELSE, WHILE. I tackled the first part and now its onto the 'easier' part even t

View 1 Replies View Related

C++ :: Check If Binary Search Tree Is Full Or Not Recursively?

Dec 5, 2013

How would I check if a binary search tree is full or not recursively?? ?

View 1 Replies View Related

C Sharp :: Full Code For Webcam Alert Motion Detector?

Mar 12, 2013

i have webcam i need to make project when this webcam detect any motion in his spot give me alert ,,,

View 4 Replies View Related

C++ :: Program To Read Middle Names Within Text File - Full String Not Appearing

Oct 24, 2014

I've a problem here...

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
#include <iomanip>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])

[Code] ....

The program needs to be able to read the middle names within the text file named Info2.txt

Simply adding the Mname or any related value where the other to name values doesn't do anything and only the 1st line appears on the output.

Don Jon111012
Jack Bo Todd151015
Jill Jo Jane161011
Bob Jack Chuck 131513
Da Fu111012

That is the correct way it appears in the text file. Also I know it's commented out, but that just to keep the program from crashing.

current output

Survey Results:

Name Results
Don Jon 33.00

This is the Info1.txt file info by the way.

Ken A202017
Gus B151015
Bill C151512
Jara C151720
Lu E101510
Chow B171015

And the output

Survey Results:

Name Results
Ken A 57.00
Gus B40.00
Bill C42.00
Jara C52.00
Lu E35.00
Chow B 42.00

Which when ran with Info1 selected, it is the correct output I'm looking for. I've tried getline and other solutions and they didn't work.

View 1 Replies View Related

Visual C++ :: How To Detect If Window Media Player Is Running In Full Screen Mode

Jan 21, 2013

How can I check if window media player is running in full screen mode & topmost in c++ MFC?

What I used is this logic:

I compared media player full screen coordinates to that of monitor coordinates.If they are same implies media player is in fullscreen.But it has one flaw.Whenever there are control(for play,pause) displayed in full screen in media player, coordinates are not coming same as that of monitor.

View 10 Replies View Related

C/C++ :: Priority Queue Without STL

Nov 28, 2014

How to build a FiFO queue without using the STL (done that no problem), get it to dequeue (again, done that no problem). However, to get those extra marks, I need to be able to order it using a priority system.

I've tried ordering the NodeDequeue class that I'll show at the bottom of this post, but I just cannot get it to order appropriately. The closest I have got is everything in order but I lose a Node from the memory completely. So, that's no good.

The most logical idea I have thought of right now is to send the largest number to the back of the queue each time it's iterated, eventually, the largest number will end up at the front.

class PriorityQueue : public Queue {
public:
Node* NodeDequeue(void) {
Node* tmp = front;
Node* seek = tmp->getPrev();

[Code] .....

View 3 Replies View Related

C :: Removing Item From A Queue

Aug 17, 2014

I'm having a problem with removing an item from a queue. At first in the debugger I got SIGTRAP but I don't get it anymore but the problem still exists. When you try to remove an item from the queue the first nothing happens. Here's the code below compile it and you see what I'm talking about.

Code:

#include <stdio.h>
#include <stdlib.h>
struct Node {
char let;
struct Node *nextNode;
};

[code]....

View 12 Replies View Related

C :: Display The Names In A Queue

Mar 12, 2014

I have an assignment that needs to display the names of customers to be served according to a sequence. coding to display the names accordingly?

Code:

#include <stdio.h>
#include <stdlib.h>
#define MAXIMUM 20
void create();

[Code].....

This is my output. I have trouble displaying the names of the customers as it outputs null when I try to display my position in queue.

View 4 Replies View Related

C++ :: Decrease Key In STL Priority Queue

Jan 19, 2013

I'm trying to implement Prim's Algorithm and for that I need to have a decreaseKey method for a priority queue (to update the key value in a priority queue). Can I implement this in the STL Priority Queue?

This is the algorithm I'm following:

for each vertex u in graph G
set key of u to INFINITY
set parent of u to NIL
set key of source vertex to 0
en-queue to priority queue Q all vertices in graph

[Code] .....

View 1 Replies View Related

C++ :: How To Resort Priority Queue

Nov 4, 2013

I've got a priority queue of items who, from time to time, returns a different comparison result. Any way to re-sort a priority queue who is storing them?

Example:

#include <cstdlib>
struct Random {
bool operator<(const Random&) const { return !(rand()&1); } };

View 10 Replies View Related

C++ :: Passing Object By To Queue

Dec 4, 2013

I've been working on a little project and hit a snag. I'm using nodes for a queue and stack class that were created using an existing list node class. I create an object for a student class and I want to enqueue that object.

int main() {
Queue sLine;
Customer stu;
Queue<Student &>
cLine.enqueue(cust);
}

That's basically the coding of it in main. However when I follow the error which says uninitialized reference member ListNode<Student& info>::data;

#ifndef LISTND_H
#define LISTND_H
template< class T > class List;
template< class NODETYPE >
class ListNode {
friend class List< NODETYPE >;

[Code] .....

What I may have been doing wrong? Trying to work within certain contexts.

View 2 Replies View Related

C++ :: Creating STL Queue Of Arrays?

Dec 3, 2013

Is there any possible way to create an STL queue of arrays? I tried

queue<int[]>q;

It didn't work?

View 2 Replies View Related







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