General C++ Programming - February 2019 (Page 2)

void trimArray(const char *toTrim, char *newArray)
 
This is my code but it is wrong // The function trimArray() is given a pointer to a character array that// is NULL terminated called toTrim. This function is t...
[1 reply] : try something like this. if(input == 0) return 0; //null pointer inpu... (by jonnin)
String Help
 
how do you move the last 3 values in a string of unknown length to the beginning and add a #. for example: hello would become #llohe
[2 replies] Last: or putting that together you get: mystring = "#"; mystring += orig.sub... (by jonnin)
Single Player Battleship
 
Here is the code for the 2 boards, both need to be visible when running. reate 2 boards (Player view and CPU view) - 10 x 10 character array Display the board...
[1 reply] : Start without the randomization. Start by trying to place a single sh... (by doug4)
by frek
Return from a vector and dereference it
 
Hi, Why doesn't the code below work please? #include <iostream> #include <vector> using namespace std; auto test() { vector<int> vi = { 2, 4, 6 }; return...
[4 replies] Last: When you initialize p , vi has no contents, so vi.begin() is the sa... (by doug4)
by frek
How to get the user select a type
 
Hi, Here in this code, " ob " doesn't work after the conditions, and that's because it has been created inside those blocks. Is there a way to receive the typ...
[7 replies] Last: [quote=frek]That is, for every data and function in ObT, we need its a... (by lastchance)
by frek
Get the value of binary tree nodes by iterators
 
Hi, We have a class btree for a C++ binary tree. bt is an object of that class and the class has three member functions (as below) to return a pointer for ...
[2 replies] Last: In the binary tree program, we have a class called btree which appar... (by frek)
by iiAlex
HELP PROJECT DUE IN AN HOUR
 
The user is required to enter a character to represent the package chosen. If a character other than ('A', 'a', 'B', 'b', 'C', 'c') is entered, the program prov...
[17 replies] Last: What I meant was the 'result' is the same as size never begins with - ... (by Grime)
by H00G0
Interacting with a loop from outside its scope?
 
Hey guys! Following my last post on me trying to build a console GUI with SDL_2. I'm running into a bit of an issue, by running I should rather say faceplant...
[13 replies] Last: What do you mean by it changes the local copy of thread A or B? Yes I ... (by jonnin)
If statement not working as intended
 
In the third sections the ifs are intended to select a monster depending on the modulo of rng, but if d1=1 and d2=1 it selects Goblin instead of Rat. main ...
[7 replies] Last: Resolved all issues, thread closed :). (by Yuripetrocchi)
Program gone haywire when user input is a character
 
#include <stdio.h> void calculation(void); void menu(void); main() { int x = 0; do { printf("Welcome to the Health Club!\n"); printf("Health...
[2 replies] Last: Mmmm. > do scanf( "%c", &ch ) ; while( ch != '\n' ) ; Doesn't take in... (by salem c)
Switch case HW
 
#include "stdafx.h" #include <iostream> // i/o library #include <string> // string library #include <iomanip> using namespace std; // stan...
[3 replies] Last: Please edit your post to put [cod e] tags around your code. ... (by salem c)
The following program outputs a segmentation fault (core dumped). I need help figuring out what is wrong. Thanks in advance
 
#include <iostream> #include <algorithm> #include <string> #include <map> using namespace std; class Component; //Medical Devices class MedicalEnt...
[6 replies] Last: Thank you all for the hints you provided. The issue was resolved after... (by mou541gf)
HOMEWORK HELP
 
Hello I can't seem to figure out why my code skips over the gymmast's name, can someone help point out what I'm doing wrong. This is a for and while subject. ...
[1 reply] : I placed the comments on your code to give you an idea. Please, note t... (by chicofeo)
Do while help
 
In this code, when the program is repeated, it skips over the salesperson's name entry. Can someone point out what I'm missing #include <iostream> #include <s...
[1 reply] : Have you learned about cin.ignore() yet? I placed it in your code with... (by chicofeo)
RE-ENTRY HOMEWORK HELP
 
So I made most of the code work, it's just I can't get to reentry after a negative gets inputed, it will go onto the next month instead of asking the user to re...
[1 reply] : To validate a negative input, I would use a while loop. For example, ... (by chicofeo)
Priority Queue with heap input string and int
 
I got a Priority Queue implemented using heap with integers but i would now like to add a string with it. I can't find any thing to help me or understand on how...
[2 replies] Last: Do i declare this in main or in my header file? Also i don't use any f... (by TomRyan12)
Help with Increment and User Input
 
For my project, I need to count how many times the user has inputted the letters in Bacon/. There are six inputs separately. I can't figure out how to stop the ...
[1 reply] : //int RolltheDice1; char RolltheDice1; (by ne555)
by Grooth
overloading << only prints out address
 
I want my display method to show up, but I only get an address that the values are stored in. input values are 2 rows, 2 cols with the values of 2 2 3 5. T...
[1 reply] : I'm saddened that that even compiles for you, because you're trying to... (by Ganado)
thread for member function of object in vector of unique_ptr
 
I have a vector of unique_ptr of a class Tower. The unique_ptr is to stop object slicing for derived classes. I want to put the function drawTower on another th...
[4 replies] Last: Oh, that makes sense now (by dudeawsomeness1)
February 2019 Pages: 1234... 11
  Archived months: [jan2019] [mar2019]

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