Beginners - June 2019 (Page 3)

for
 
Hello, I want to ask, for(int i = 0;i < many;i++) { getline(cin,other .name); } cout << other .name; In this program other .name is what I input in the...
[2 replies] Last: Your second example is using a copy of your array, so any changes made... (by George P)
matching a string to struct value in an array of structs
 
Currently I have a working heartbeat client that will echo a key to the server. The issue i'm running into on the server side is matching the client's key to a...
[3 replies] Last: The following is not allowed in standard C++: while (getline(CLIE... (by jlb)
DP (1,2)
 
A function is defined as f(n+2) = 2*f(n+1) - f(n) + 2 , if n is even f(n+2) = 3*f(n), if n is odd f(1) = 1 ,f(2) = 1 n > 0 Help me code this function by recur...
[20 replies] Last: @counter strike it gives answer of 70282652 but answer is 26030209 T... (by SparkXV)
Need help adding a Yes continue/No end program loop
 
I don't know how/what/where to add a loop to continue if you type Y or end the program if you type N to the first question in my code. #include <iostrea...
[2 replies] Last: #include <iostream> #include <cstdlib> #include <ctime> int main() {... (by JLBorges)
cin ambigous error
 
getting a cin ambiguous error and else "expected a statement error" everything was working until I tried adding a if statement to close the program if the answ...
[2 replies] Last: That fixed it, thank you so much! (by hjabba89)
Calculation
 
How do I do the calculation for "width * height * length" #include <iostream> #include <fstream> #include <cmath> #include <string> #include <iomani...
[1 reply] : Ok, clearly this is new to you. That's not a problem. First, since yo... (by Niccolo)
char array Memory deAllocation
 
Hello Guys i am bothered that my dynamic array is not de allocating memory and gives an error If i comment the lines "delete arr and delete arr1" in the code...
[7 replies] Last: Really leant alot Thank You (by Abdul hadi)
Philosophic reason for initializing members as apposed to initialization function??
 
OK gang, Back for more questions and I did look this up FIRST but was unable to really match a correct answer. Maybe I didn't understand it even though I sa...
[4 replies] Last: @Dutch might notice something, but my quick read is "yes", you got it.... (by Niccolo)
I created my self a decimal challenge accidentally but can you figure it out.
 
#include <iostream> #include <string> #include <math.h> #include <iomanip> using std::cout; using std::cin; using std::getline; using std::string; using s...
[5 replies] Last: All I know is the code above works, so does the bottom one. The probl... (by Shibitto)
Class can't access my vector
 
Still very new to c++ and programming in general. Although I've been picking it up quickly. However, I've hit a roadblock. I created a vector to store my class ...
[10 replies] Last: You get told a Bunny has died every time one is destructed. Bunny b... (by Repeater)
Error assigning struct value from getline
 
Currently I have a text file that consists of multiple names and keys deliminated by ";" like so: client1:client1skey client2:client2skey client3:client3sk...
[2 replies] Last: Thank you so much lastchance that solved it. Updated code for anyone e... (by foxxthegreat)
by Deluge
Char Data Getting Corrupted
 
I'm trying to create a type that has a char array and integer id members: class ResourceObject { public: ResourceObject(const unsigned char* data, const i...
[8 replies] Last: sorry. I have a form of visual issue where front loaded variables all... (by jonnin)
by tinaHR
Drill from Bjarne's book
 
Hi all, i am going through Bjarne book and at the moment im doing chapter 4 drills. The program i wrote seems to be working but im wondering, is there anything ...
[6 replies] Last: About bool and test I meant how come in int test = false; i can... (by tinaHR)
Exiting a loop early
 
Hi, I'm trying to print out the first number in a loop that doesn't exist inside an array of numbers. I'm using a double nested for loop. The methods I've trie...
[14 replies] Last: Input is tedious: size_t N {}; if ( !(file >> N) ) return 1; ... (by keskiverto)
Pointer
 
Hello, I want to ask When will we need to use pointer?? Actually what is the benefit of using pointer?? What make pointer different from the usual progra...
[5 replies] Last: pointers and their power don't really make sense until you understand ... (by ICantC)
getline
 
Hello, When I use getline(cin,var) sometimes it is skipped. Why is it skipped?? I know there is cin.ignore(); , but it doesn't mean I must use it whenever I ...
[1 reply] : If the stream is valid it is not skipped. It may be called at a point... (by lastchance)
If else statement (1,2)
 
I'm struggling with a code and I'm using if/else statement. I'm extremely need to coding here so bear with me and thank for any help. When I add a formula in my...
[34 replies] Last: [quote=Cjigsaw]I do hope I can pm you to pick your brain. Why would y... (by MikeyBoy)
Dynamic programming
 
https://cses.fi/problemset/task/1746 I have thought of this question for a while now, can't really see the subproblems for DP, brute force will surely give a...
[10 replies] Last: Basic shape is a rhombus. a * * * * s * ... (by dutch)
If setw sets "minimum field width", why does it limit input or output?
 
If I write: 120 450 340 as input, I only get 120 back. I don't get it. int main() { int x{}; cout << "Enter nr: " << endl; cin >> setw(1) >> ...
[1 reply] : The setw() is irrelevant here. (For an input stream it is only relevan... (by lastchance)
Merging two of c++ games into 1
 
Our prof gave us two game program one is Snake and the other is Dinosaur. he required us to merge two games in a single program just like a game library but wit...
[1 reply] : Sure, you rename the two main functions to be playSnake() and playDino... (by salem c)
June 2019 Pages: 12345... 13
  Archived months: [may2019] [jul2019]

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