General C++ Programming - January 2020

Why does cin get skipped?
 
I have this short snippet: int main() { cout << "User Input... "; int userChoice = NULL; cin >> userChoice; if (userChoice == 1) ...
[13 replies] Last: Cool, thanks! (by closed account Ey80oG1T)
Graphics Menu in C++
 
I am working on a project and I want to make a Graphics Menu. Issue which I am facing is that after it shows any text written in the function I've put in swit...
[1 reply] : Could you provide a minimal reproducible example? (by closed account Ey80oG1T)
Learn how to use vectors
 
Hi! I was searching a nice tutorial to learn all about vectors. Does someone recommend a specific site? Thanks...
[9 replies] Last: Tada ... (by againtry)
Why does an integer prompt accept strings?
 
I have this code... int userChoice; cin >> userChoice; if (userChoice == 0) cout << 0; if (userChoice == 1) cout << 1; else cout << -1; How...
[5 replies] Last: Whitespace doesn't matter. if (a) part_of_if_statement(); ... (by Ganado)
by GisiNA
How to see the content of a specific memory having only the address
 
Hello all! First of all... Sorry for my English. :-) Now to my problem. I am trying to see if it is possible to read the content of any part of the memory, b...
[6 replies] Last: It requires asking your operating system to let you read the memory of... (by Repeater)
Get the last digit of a number
 
How can I get the last digit of an int?
[14 replies] Last: Sigh. Sorry about that … I hate when I do that (by jonnin)
WoW, I didn't know what emplace(_back) function is faster than push(_back)..
 
I was just testing emplace_back or push_back(vector) or emplace or push (stack) and I got new info(just for me) that when a type of container is an object, empl...
[6 replies] Last: I was just testing emplace_back or push_back(vector) or emplace or pu... (by mbozzi)
Breadth-first traversal for top down tree
 
template<class BaseData> inline void TDTree<BaseData>::breadthFirstTraversal(void(*processnode)(BaseData& value)) { /* std::queue< GtNode<BaseDat...
[3 replies] Last: > 't' has a first child 'h' and its siblings 'r' and 'e'. ¿how do you... (by ne555)
A shopping bill
 
I have a school project to make, I've been asigned with 2 other people who has no idea what programming is,I really need your help with this, I have to present ...
[6 replies] Last: #include<stdio.h> #include<string> #define max 50 int main() { int l... (by codyy)
Extraction of data from .txt file
 
Hi Guys i have a file name ABC.txt and it includes the following data: login as: rokob Using keyboard-interactive authentication. Password: Access deni...
[7 replies] Last: You're looking at use of #include <iomanip>, setw, right, left etc Us... (by againtry)
0's of a factorial
 
I want to make a program which takes a number n and then outputs how many 0's the factorial has on the right site of the factorial. For this, I thought about...
[9 replies] Last: Oh ok. Haven't seen dutch's comment (by yabi2943993)
by Odglog
Per Object Function
 
Hello! This is a quick one, is there any way to make a class with a member function that gets defined by the object itself? For example: #include <iostream>...
[13 replies] Last: Thanks everyone for the help! I think I will go with @mbozzi approach.... (by Odglog)
Drawing a chess table
 
Hi. I want to make a program which draws a chess table. This table should not contain white and black fields. The fields should be made of spaces and simbols. T...
[7 replies] Last: Thanks to all for your help! (by yabi2943993)
Can there be more than one n0 of a function in Asymptotic Notations?
 
Considering the case of Big-O here (as an example), you would know that, f(n) is O(g(n)), if for some real constants c (c > 0) and n0, f(n) <= c g(n) for e...
[3 replies] Last: Once you identify a value n0 for which f(n) <= c g(n), EVERY INPUT SIZ... (by doug4)
array type to Array class type
 
How could we convert a primitive array type to Array class type as in Array lib. so it's size can be initialized dynamically by ... *arr = new ... , yet it stil...
[3 replies] Last: what problem are you trying to solve? New/delete calls done foolishl... (by jonnin)
binary calculator using vectorbool in c++
 
I´m trying to write a program in C++ in which I could std::cin a binary number of the type std::vector with random length and then std::cin one of the followin...
[1 reply] : we can't fix it without seeing it... post your code (in tags, the <> t... (by jonnin)
How do I find 10 most popular names from HUGE string array, it has like 850 names???this is a school project
 
void insertInMap(map<string, int>& m, string s){ if(m.find(s) == m.end()){ m = 1; } else{ m ++; } } void checkAns(map...
[11 replies] Last: Here's what I meant. #include <iostream> #include <map> #include <str... (by dhayden)
What is this way that something weird return?
 
I was solving Leetcode, and I saw someone's code. and I saw an interesting code that when a function returns vector<int>, It returns like this way. vector<in...
[4 replies] Last: Thank you, guys!! (by woohyeon)
Working with debug and optimized builds in one project
 
I've gotten my project to a point where it segfaults, so I'd like to use the debugger to find out how this happens. The problem is though, my project is set up ...
[1 reply] : I haven't used CodeLite before, but just as a cursory glance, it appea... (by Ganado)
How do I turn word into a list of letters
 
If I am given a string say "helloworld" , how do I convert it into a list say l which is ["h","e","l","l","o","w","o","r","l","d"]
[3 replies] Last: If you mean a std::list and a std::string, something like std::list<c... (by Repeater)
January 2020 Pages: 123... 9
  Archived months: [dec2019] [feb2020]

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