General C++ Programming - June 2021

Sort an input file for a specific value
 
Hello, I am trying to sort an input file by a specific value (price), then print the sorted list to an output file. Example input text (how it it formatted in...
[9 replies] Last: Thank you everyone. I was able to finish the project. (by Fayezilla)
Help with partial match peg counter in Mastermind game C++ code
 
Like the title says, I am coding mastermind in C++ have already completed it, the counter pegs are gold for a pure match, and silver for a partial match. I have...
[4 replies] Last: #include <iostream> #include <vector> using namespace std; template... (by dutch)
Reading binary file data into struct object?
 
Hello. I do not know if it's the right way to do this, but I have this code: #include <iostream> #include <fstream> typedef unsigned int u32; typedef uns...
[5 replies] Last: How did you write the information to the file? You really shouldn't b... (by jlb)
by Borneq
Smart pointers and trees
 
I have Node: int level string name Node* parent std::vector<std::unique_ptr<Node>> childs; I create Node with level and depend on level, link to last node ...
[4 replies] Last: Perhaps something like (NOT tried); #include <memory> #include <str... (by seeplus)
Why do I need to use “pointer to pointer” in this situation?
 
why I have to use "pointer to pointer" in the function "InsertAtFront" This is the reason: (*head) = newNode; You set the head pointer to newNode . If ...
[5 replies] Last: OP is a spammer. Yeah. The original post has now been deleted - wh... (by seeplus)
Concrete types - as described by Stroustrup - C++ Programming Language 4th ed
 
In my understanding: A type whose 'representation is part of its definition' is a type for which we can use value semantics. For example std::string A type...
[2 replies] Last: Sadly this question is another re-post. Wait for the edit and spam. h... (by lastchance)
How to append text to a text file in C++?
 
Dratted re-post bot: original question from https://stackoverflow.com/questions/2393345/how-to-append-text-to-a-text-file-in-c #include <fstream> using namesp...
[1 reply] : See under mode in http://www.cplusplus.com/reference/fstream/ofstream/... (by seeplus)
Is there a standard definition for __cplusplus in c++14?
 
__cplusplus denotes the version of C++ standard that is being used, expands to value 199711L(until C++11), 201103L(C++11), 201402L(C++14) , 201703L(C++17)...
[3 replies] Last: why does OP have a link to walgreens? Looks like a low quality spam o... (by jonnin)
by cmisip
How to make base class use derived class overloaded method
 
Is it possible? If I derive a class, then override one method, is there a way for the base class to use this method? class Base{ void writebyte(){}; ...
[4 replies] Last: It's a publicly available arduino library called TM1637_6D. I derived... (by cmisip)
i need help
 
After level 5 lockdown, Rose, Rebecca and Rachael (three friends) realized that they had gained much weight. Therefore, they decided to do exercise activities...
[9 replies] Last: PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting co... (by AbstractionAnon)
How do i censor specific words in a string?
 
#include <iostream> #include <iterator> int main() { std::string vect = "one two nyes four nyes five nyes six"; std::string ban = "nyes";...
[4 replies] Last: Hey Einsteins, it's a two-year-old account blatantly posting spam. (by Ganado)
difference between char array and string in cplusplus
 
I need to know the difference between character array and string in c++. Can any one answer to this? Thanks in advance. https://www.mybalancenow.b...
[1 reply] : https://duckduckgo.com/?q=difference+between+character+array+and+strin... (by salem c)
by cmisip
Can a struct in a vector access its index in the vector?
 
I am building a vector of structs. The struct will contain a data member which is a pointer to an array of double. I need to have the struct member pointer to ...
[13 replies] Last: You're right. There's not much to gain going down this road. The sim... (by cmisip)
by suckss
Dynamic array of char arrays
 
The title might seem a little confusing but I'll try to explain. I have a struct and I know I'm getting a certain number of char arrays, which have a constant s...
[8 replies] Last: that will cause you some troubles. If you leave off the space for th... (by jonnin)
Trying to print adresses of 2D dynamic arrays
 
I've created a program that is able to create a staggered 2D dynamic array. I pass this array to function and try to cout it's "childrens" memory locations in t...
[1 reply] : arr is the value stored in the i'th element of arr . That means i... (by MikeyBoy)
Find the first two consecutive pairs in the vector with greatest equal second (1,2)
 
One last question regarding vector of pairs. Suppose we have a vector of pairs like the following: V { (1,10) (4,20) (3,50) (6,40) (8,50) (10,30) (7,40) (12,5...
[24 replies] Last: Well, I finally managed to run the code on Wandbox: https://wandbox.or... (by lastchance)
detect mouse cursor position in a particular window
 
Ok, so how do I detect mouse coordinates in a particular window ? detect mouse coordinates give general screen coordinates of the entire screen: POINT p; ...
[1 reply] : Try ScreenToClient: https://docs.microsoft.com/en-us/windows/win32/api... (by dutch)
aggregation relation
 
Why the case 3 cannot display? class Item { public: string itemName; double totPrice; double itemPrice; int quantity; //Item(){} ...
[14 replies] Last: Well if you made Payment have a pure virtual function, you can't decla... (by Ganado)
I'm given a sequence containing from 3 to 30 words. Printing all words that occur more than once in the sequence.
 
I'm given a sequence containing from 3 to 30 words, each of which contains from 1 to 5 capital Latin letters; between adjacent words - a comma, after the last w...
[4 replies] Last: if Xcode lacks a friendly debugger, then just insert some print statem... (by jonnin)
Implement an array-based stack and count what is more in the stack
 
Implement an array-based stack and count what is more in the stack - vowels, consonants, or other characters. Then implement the stack based on the linked list ...
[4 replies] Last: How can i do this in Xcode? (by sergeyutkin221)
June 2021 Pages: 123... 5
  Archived months: [may2021] [jul2021]

This is an archived page. To post a new message, go to the current page.