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