General C++ Programming - June 2017 (Page 6)

by Bank
Why is this program working?
 
for this question: someone had a plan to access another person's computer and the plan was to send a huge amount of n different natural numbers from 1 to n to...
[4 replies] Last: @Bank: the code is equivalent. you had return result(m+1, /**/); tha... (by ne555)
by varmy
The Initialization Problems in Program
 
Good morning~all I am measuring QEA and QEB of DSPIC30F2010 with the frequency 100KHz. The wave is perfect,there are no attenuation and distortion. A up-pull r...
[no replies]
by Kalcor
BST Implementation.. correct?
 
I couldn't understand something in this BST implementation, first here is the insert function: BstNode* GetNewNode(int data) { BstNode* newNode = new BstNode...
[2 replies] Last: Yea you right when I traced the recursion later on I got why both meth... (by Kalcor)
Adding border
 
So I'm trying to add a border around my menu. Someone told me to try using screenloc() and box(). However, they are undefined in my code. I'm not familiar with ...
[6 replies] Last: For simple jobs it's often easier to hardcode the menu as follows; #... (by closed account 48T7M4Gy)
by Kalcor
A way to make infix > postfix with more than 1 char/digit
 
So I implemented a stack, that should turn an infix to postfix but sadly, I can't get it to work for more than 1 digit/character, for example a or 1 works but 1...
[2 replies] Last: @kbw Ah I'll try that, thanks! (by Kalcor)
by Kalcor
Parentheses checker logical error
 
This below, is an implementation of stack method for parentheses checker, this code works extremely fine except for 1 case.. where i input (a+b)) or ()) just ...
[2 replies] Last: if(s == ')'){ if(checker.top_element(top) == '('... (by ne555)
Searching 2D array
 
I am attempting to search for a string value in a 2D array based upon an inputted username. This code builds, but does not correctly search it. Please help ...
[6 replies] Last: #include <iostream> #include <fstream> #include <iomanip> #include <s... (by doublemirchi16)
An imaginary lock mechanism.
 
Here comes our scenario. Simply, Bob and Alice are a write and a reader. Bob writes things and Alice reads it. Rules are: 1) Bob can write no matter Alice is...
[4 replies] Last: Thank you Cubbi, Seqlock is the answer. (by nemonemo)
by Kalcor
Is this a correct use of delete?
 
Did I use delete correctly in this code snippet? void pop(Stack *&top){ if(top == nullptr) return; Stack *temp = top; temp = top->n...
[5 replies] Last: Your delete is fine (with the above assumptions from @Peter87), but yo... (by doug4)
Functions not working
 
So I got the first function, is digit to work, but not the others. I'm confused because I used them the same way but obviously, that is incorrect. The other fun...
[1 reply] : Return Value A value different from zero (i.e., true) if indeed c ... (by integralfx)
Need some help with arrays and functions
 
Hi(sorry for bad english), I have some trouble with this i'm supposed to create 4 functions 1st print matrix 2nd count pair, non-pair numbers 3rd create an a...
[1 reply] : Please, always use codetags (the <> formatting button) when posting co... (by chicofeo)
by Kalcor
Linked list question
 
So I was implementing a function that adds data to the tail of the linked list so I tried 2 things one of them worked and one of them doesn't work(crashes) so ...
[3 replies] Last: `head' is a pointer, so you must be assigning a memory address. `temp'... (by ne555)
by Kalcor
XOR Swap algorithm weird error?
 
I was implementing a quick sort on some array but I encountered this weird error: int part(int a , int low, int high){ int piv = a ; int index = low; for...
[3 replies] Last: xor swap is also slower usually. The cpu has to do the xor AND the sa... (by jonnin)
by Disch
(Templates) Variable args
 
Hey all. Long time no see. Sadly I don't have the time to keep up with these forums like I used to. =( But I had a C++ question and figured the people here...
[2 replies] Last: Perfect. Thanks JLBorges. Yes I know to use make_unique. I was just... (by Disch)
Strings in C++
 
I use Dev-C++ which has GCC 4.9.2 C++ compiler. I am confused on where and where not to use the following for declaring a string variable: 1. include <string>...
[3 replies] Last: [quote=abhinav mathur]1. include <string> only 2. include <string.h> o... (by Enoizat)
by Kalcor
Is it possible to return an array?
 
Is it possible to create an array within a function and return it at the end of the function ? Also what does having a pointer function mean like int *foo(/*....
[4 replies] Last: > Is it possible to create an array within a function and return it at... (by JLBorges)
by Kalcor
What does this expression mean
 
Sorry for posting for such a short question but what does this int *&s1 mean?
[3 replies] Last: Do you have Google? Perhaps wiki ? (by TheIdeasMan)
Runtime error: Process terminated with status 255
 
I am trying to find the 10001st prime number. It shows runtime error. #include<iostream> using namespace std; void pnum(int n) { long long int i,j,a ,cnt=0; ...
[6 replies] Last: @ne555 yeah! it was because of array size being too small. (by carleye)
Difficulty with Abstract class
 
In my program given below: #include <iostream> #include <ostream> using namespace std; enum Month{ jan = 1, feb, mar }; class Show{ ...
[2 replies] Last: [quote=napada99]I'm getting a garbage value for Month m What do you p... (by Enoizat)
Help solving Rate and Hours Problem
 
Create a C++ program to calculate and display an employee’s weekly gross pay. The program should ask for the number of work hours in a week and the hourly pay...
[5 replies] Last: Read the Arguments passed by value and by reference section http://w... (by integralfx)
June 2017 Pages: 1... 45678... 11
  Archived months: [may2017] [jul2017]

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