C++ ::  NCurses Outputting Vectors

May 19, 2013

The following code works perfectly with "normal" C++

#include <iostream>
#include <vector>
int main() {
std::vector <std::string> hello {

[Code] ....

This prints "HELLO" on the screen. A function a bit more like NCurses is:

for (std::vector <std::string>::const_iterator it = hello.begin(); it != hello.end(); it++) {
std::string temp = *it;
std::cout << temp.c_str() << std::endl;
}

This still works with "normal" C++. Now, how do I get this working with NCurses? I tried

#include <curses.h>
#include <string>
#include <vector>
int main() {
initscr();

[Code] ....

But this just gives me an empty screen.

View 2 Replies


ADVERTISEMENT

C++ :: How To Start Using Ncurses

Sep 3, 2013

It's written here: URL....But those links don't work. I can't understand how to start programming using ncurses.

View 9 Replies View Related

C :: Getting Started On Rogue Using Ncurses Library

Feb 16, 2013

I've been assigned to program rogue using the ncurses library, which will need

1. File I/O
2. String parsing
3. User input (h,j,k,l)
4. Room drawing

And Where i can start with this program?

View 4 Replies View Related

C++ :: Adding Content To Window Using Ncurses

Aug 12, 2013

I'm makeing a card game with ncurses. I have all the card and player objects in order but i'm stuck trying to get the gui to work.

I'm using multiple windows for different players deck and pile. Now to the problem: I can get all the windows to show with borders in the console but i can't get any content printed in the windows and I rally can't see why!?

I have been reading the guide on [URL] but I don't get any further on the problem right now.

PS. the complete code incl. Makefile can be found at:
github.com/DanBrehmer/cardGame
#ifndef GUI_H
#define GUI_H
#include <ncurses.h>

[Code]....

View 3 Replies View Related

C++ :: Ncurses - Highlighting A Line Of Characters On Screen

Oct 25, 2013

I am writing a program using ncurses that needs a function to highlight a line of characters on the screen. I started writing this function that took the x & y coordinates of a character on the screen and the length of characters after that to highlight. Whilst doing this I noticed that if I highlighted the last character in a row (maxX-1 in my example) it highlighted that character (as expected), and if I highlighted just the character before that (maxX-2) it also works. But if I do both, it highlights the whole row/line. Also, if there are characters in those spaces other than the 'space' character it works too, but for my program I need to be able to highlight empty spaces as well.

To highlight I am using inch() to get the character and addch() to print it because I am using some alternate characters that chgat() replaces with normal characters.

#include <ncurses.h>
int main(){
initscr();
start_color();
use_default_colors();
curs_set(0);
noecho();

int maxX=0, maxY=0;

[Code] ....

View 3 Replies View Related

C++ :: List Of Vectors (vector Of N Vectors Of M Elements)

Mar 19, 2014

I create a list of vectors (a vector of n vectors of m elements).

std::vector <std::vector <int> > vsFA (n, std::vector<int>(n));

How I assign values? I try below, but not worked

void armazenaFA( std::vector <int> &vFA) // this function only knows about vFA
{ vsFA[n] [m]= simTime().dbl();
OR
vsFA[n].push_back(simTime().dbl());
}

View 1 Replies View Related

C++ :: Make Terminal Screen Bigger In NCurses Program?

Jun 29, 2013

I wanted to make the terminal screen bigger in my NCurses program. Let's say if the defaults are 25 LINES and 80 COLS, I want to set them to 40 LINES and 120 COLS.

I've tried resizing all windows, but that did not work, because the actual terminal (console) was not resized. Then I found functions resizeterm and newterm, but they did not work. As far as my understanding goes resizeterm only updates NCurses information with the current configuration, while the window itself is not actually modified.

NCurses man page wrote:The function resizeterm resizes the standard and current windows to the specified dimensions

If I haven't made myself clear ( I sometimes make a mess of things... ), another example would be that I want my program to be fullscreen when I start it. Is this possible? It should be, I found a fullscreen NCurses program once, but the code was too confusing for me to understand.

Having read about things like SIGWINCH, I assume you must define a method for resizing the terminal screen yourself, I don't know where to start?

View 11 Replies View Related

C++ :: Create Two Vectors And Then Loop Through The Vectors

Sep 19, 2014

This is probably a very basic question, but I need to create two vectors and then loop through the vectors and output each pair that is found.

The user will input min1 and max1 with step1 for the first vector and min2 and max2 and step2 for the second vector. Then the loops will go through and return the combinations will return each pair of the two vectors.

So if I input min1=1 and max1=10 and step1=1 and same for vector two the return would be:

[1,1]
[1,2]
.
.
.
[10,10]

This is for part of a homework assignment, but I can't continue on the assignment without first getting this simple part to work.

View 1 Replies View Related

C++ :: String Outputting Twice?

Nov 3, 2014

When I run the program, the prompt I am giving the user before I collect their data, shows up twice in row. Here's the part of the code I'm referring to:

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
// method prototypes
void characterInstructions();
void phraseInstructions(); //

[Code] ....

View 6 Replies View Related

C++ :: Outputting Associated Data In Struct

May 2, 2013

So this is the last part of a program I've been working on for four weeks now. This question may be a tough one considering the amount of files included in the program.

The program is to read in a file of requests between two cities, read in a file of flights and cities that occur between the cities. It then checks to see if there is a path between the flights and output an itinerary. I have the correct itinerary outputting, but when attempting to output the associated flight number and price according to the city, I am getting odd data. How can I output the correct flight number and price associated with each flight on the itinerary.

I'll post out the output I am currently getting and the section where I am outputting the data. I'm sure I'll need to post more files so the program can be understood.

Don't want the code done for me, just a point in the right direction! I don't want to let this program defeat me!

Output: Code: Request is to fly from Atlanta to San-Diego.The flight itinerary is:
Flight # From To Cost
10 Atlanta Chicago $134529069
10 Chicago Miami $134529069
10 Miami Dallas $134529069
10 Dallas San-Francisco $134529069
10 San-Francisco San-Diego $134529069
This function finds a path between cities. Code: bool flightMap::IsPath(string originCity, string destinationCity){
StackClass aStack, bStack;
flightStruct flightRec;
string topCity, nextCity;
bool success;
int index = 0;

[Code].....

View 1 Replies View Related

C++ :: How To Pause After Outputting Results

Feb 19, 2013

I mean on the executable file. It just displays the results and quickly flashes away, cin.get() has no effect and system("PAUSE") is undeclared.

I never found a single sure way to pause effectively. Is there a method that works all the time? Sometimes cin.get() gets skipped even in the code itself. The IDE I am using is Code Blocks if that matters any.

View 4 Replies View Related

C++ :: Outputting Randomized Arrays

Apr 7, 2013

For an assignment I am having a user enter the name of a file that contains "Song Data" the file is set up like this:

(example)

1012 C
3333 R
90 E

And so forth for 15 lines. The first value represents the song Id and the second is a character C, D, E, or R that represents the type of song. After the file is opened I have two parallel arrays that are read from the file:

1. int songId[15]
2. char typeOfSong[15]

I am able to read the entire file, which symbolizes playing the playlist in order, but now I have to play a randomized playlist.

It has been given to us that we need to set up two parallel arrays, that are also parallel to the first two (songId and typeOfSong). These must also be one dimensional. The first array will will be indexes into the songId array telling is what order to put the songs in and the second is an array of true/false values telling us if the song has already been chosen or not.

I have that:

void playRandomPlaylist (int songId[], char typeOfSong[]) {

// the size of the file and therefore arrays is known
rand() % songId[15]

// choosen and notChoosen symbolizing true and false values
typedef enum {choosen, notChoosen};
}

View 1 Replies View Related

C++ :: Getting Data From A File And Outputting

Apr 17, 2013

I am given a data file that contains sports data for 24 people. There are two rounds of the event. The first 48 lines of the file give the data for the 1st round and the second 48 lines give data for the 2nd round. The file looks like this:

Azrin, Neil
2.3 6.0 5.0 6.7 7.8 5.6 8.9 7.6
Babbage, Charles
2.3 5.6 6.5 7.6 8.7 7.8 5.4 4.5
Burks, Arthur
2.8 4.5 5.4 6.6 7.7 8.8 5.6 6.5
Crick, Francis
1.6 6.5 6.5 6.5 7.3 7.5 7.8 5.6
and so on ............

This data continues for all 24 people and then repeats with different score values for the second round. The first number after the persons name is the level of difficulty and then next 7 numbers are the scores. I am trying to get this data out of the file and set it up in the following format:

Name Of Person
Round 1: level of difficulty scores
Round 2: level of difficulty scores

So the table for the above data would look something like this:
Arzin, Neil
Round 1: 2.3 6.0 5.0 6.7 7.8 5.6 8.9 7.6
Round 2: 2.1 6.0 5.0 6.5 7.8 5.6 8.8 7.6
Babbage, Charles
Round 1: 2.3 5.6 6.5 7.6 8.7 7.8 5.4 4.5
Round 2: 2.3 5.4 6.5 7.6 8.7 7.2 5.4 5.5

And so on for all 24 people. This is the code I have for it, but it just reads the file directly:

// I have already opened the file!
while (inFile) {
string name;
getline(inFile,name);
cout << name << endl;
}

How I can do some sort of formatting on this data?

View 1 Replies View Related

C++ :: Comparing Value To Array And Outputting

Feb 6, 2013

i have 3 arrays total, 2 of them i am comparing to see if any of the values match at all, and then i am putting the value that matches into the 3rd array. currently i am trying

int isthere (int match[], int maxmatchLength,
const int vec1[], int vec1Length,
const int vec2[], int vec2Length)
{
for (i=0; i<vec1Length; i++)
if vec1[i]==vec2[i];
vec1[i] = match[i];
}

But this will just match the same values are in the same spot. how do i fix it so that it compares one value in the first array to the whole second array, before going to the next number.

View 1 Replies View Related

C/C++ :: Getting Error When Outputting To File

Sep 5, 2014

it isn't actually writing anything to the file. It is opening the employeesOut.txt file but not writing anything. I'm getting the error

libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: stoi: no conversion
(lldb)

I believe the error is within my main.cpp, so here that is, I have multiple classes.

#include <iostream>
#include <string>
#include <fstream>
#include "Employee.h"
using namespace std;
bool openFileForReading(ifstream& fin, const string& filename);

[code]....

View 12 Replies View Related

C++ :: Overloading Using IStream - Not Outputting Objects

Mar 6, 2015

I'm implementing istream and ostream overloading for a program that takes in 3 objects, adds them, subtracts them, and multiplies them. I'm having difficulty in outputting the objects. The program outputs the first object just fine, but for some reason defaults the other two...

Code:

#ifndef COMPLEX_H
#define COMPLEX_H
#include <string>
Class Complex

[Code] ....

View 1 Replies View Related

C++ :: Sudden Exit Right After Outputting Expression

May 1, 2014

This program I'm working on just exits unexpectedly right after outputting "Expression?"

int main(void) {
provideHelpIfNecessary();
while(true){
cout << "Expression? ";

[Code] ....

And I'm not allowed to change anything in main().

View 2 Replies View Related

C++ :: Zlib Outputting Blank File?

Oct 30, 2014

I wrote a program to compress a file with gzip, which works fine. I also wrote a program to decompress the gzip file, which runs but outputs a blank file.

Code:

main.cpp:
#include "decompress.h"
int main(int argc, const char * argv[]) {
if(argc == 3) {
decompressor(argv[1], argv[2]);

[code].....

View 4 Replies View Related

C++ :: Outputting First Word Of Each Sentence In String

Dec 20, 2014

I have been trying to get this to work for a while now - with no success.

Basically I am trying to write a function which the returns the first word of each input sentence in a single string - this is part of a larger cryptography program I am working on.

So for example, if this string was passed into the function:

"This is what I mean. Is it right? A poor puppy abandoned. Secret torturing of dogs are happening. Message: be on the watch."

It should return:

//declared in class "steganalyse"
string cyphertext;
string punctuation = ".?!;:'";
book is_first_word

[Code] .....

But this only returns the first word:

This

Any other way to return the first word of each sentence in a string.

View 1 Replies View Related

C++ ::  Program To Grade T Or F Test Not Outputting Information

Jul 2, 2014

I wrote a program to grade T or F test. It is running, but not outputting the information.

Code:

#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
double grading(char*answer, char* stuResponse, double graded);

[Code] ...

text doc:

TFFTFFTTTTFFTFTFTFTT
ABC5403 TFTFTFTT TFTFTFFTTFT
ABC5404 TFTFFTTFFTFFFTTTFTFT

View 5 Replies View Related

C++ :: Outputting Contents Of Stack On Input Line?

Sep 3, 2013

outputting the contents of my stack on the input line.

View 7 Replies View Related

C/C++ :: Vector Of Class Outputting Garbage Values

Jun 21, 2014

I have a class that uses std::vector. I push back class objects onto the vector but when I try to cout the data members (with get functions) I get garbage values.

Here is the class:

#ifndef JOBS_H
#define JOBS_H
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
class Jobs{

[Code] ....

I know I am missing the implementation of several functions but I'm just testing my vector to see if it is working and it isn't. The getBlockValue() function should output 0 for each job. When I push back one object the output is 0. When I push back 2 objects the output is 0. However when I push back 3 objects I get random values. Why is this? I thought vectors were dynamic?

View 8 Replies View Related

C++ :: Outputting Transactions From A Text File To Screen

Jan 19, 2014

I am working on a wage application with four options which are as follows:

Subtracts an amount from the shop bank account (The account is text file "shop"). You do not need to add the same amount to another account but you should record the transaction with a timestamp in a separate file. The application should prevent the account balance from becoming overdrawn.

List the five most recent transactions to the screen. If there haven’t yet been five transactions then list all of them.

Print the account name, number and current balance to the screen.

Exit the program.

I have completed 1,3 and 4 but I am completely stumped as to how to go about number 2.

#include <limits>
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <ctime>
#include <string>
int read_balance(void);
void write_balance(int balance);

[Code] .....

View 1 Replies View Related

C++ :: Cout Statement Not Working - Program Outputting Zero For Variable

May 20, 2013

Why is my program outputting zero for the variable pop?

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

//capture data
cout << "Enter the world's population: ";

[Code] ....

It's obviously not std::cout, but I'm thinking its the way I'm operating on long?

View 5 Replies View Related

C++ :: How To Stop Outputting Data Based On A User Input

Sep 27, 2013

how to stop outputting data based on a user input. The text file is as follows:

1. a
2. b
3. c

and the code I'm using is as follows:

int main (){
string line;
int search;
cout << "Enter a number from 1-3" << endl;
cin >> search;
search++;
ifstream myfile ("example.txt");

[Code]...

What I want to do is to just output number 1 (the whole line) if the user enters number 1. However, I get an error on the second condition w/c is the "&& line!= search"

View 1 Replies View Related

C++ :: Outputting Partially Filled Array Onto Text File?

Jul 24, 2014

I have a partially filled array and I want to put that into a text file. Say I don't know how partially filled it is. How would I stop at the very end of the array where it has the last amount of data.

ex.
int array[9] = {1,2,5,6};
ofstream output("txt file");
for(int i = 0;i < 9; i++){
output << array[i]
}

How would I stop as soon as i becomes 4 because that is when the array stops?

View 1 Replies View Related







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