General C++ Programming - March 2022 (Page 3)

File Manipulation Search Record from a File and Edit Files Through Delete and Update Record in a File
 
Hello, I'm practicing file manipulation again and I'm having difficulty in Search, Delete and Update Record in a file. Can someone help me fix the code below. T...
[2 replies] Last: Based on 2), then consider: #include <iostream> #include <fstream> ... (by seeplus)
flattening 2d matrix how do I fix the iterations
 
This post is from a digression in a closed one. Am attempting to flatten a 2d matrix. Below I can peek at the output and see what's happening, if only minimall...
[7 replies] Last: Awesome. So a flattened 3D to 1D matrix has negligible performance di... (by jonnin)
What books did you read to learn C++?
 
My recommended book for learning C++ is: Beginning C++20 : from Novice to Professional https://www.amazon.co.uk/Beginning-C-20-Novice-Professional/dp/148425883...
[2 replies] Last: At the very least someone who actually wants help might read this. So... (by George P)
Trouble with std::async syntax
 
Hey there, I'm currently trying to use std::async to decouple a web request from the main thread, but I have a problem: I seemingly don't understand the syntax ...
[2 replies] Last: I tried both ways but got the same delay... I talked to someone on an... (by UltraBlack)
What is wrong with my code?
 
I have an issue with my code. When R1>R2 and C1>C2 it doesn't work, but if R1<R2 and C1<C2 it runs correctly. this is my code: #include <iostream> #include <...
[3 replies] Last: > if(R1<R2 & C1<C2) Also note that & is the bitwise operator and && is... (by salem c)
redistribution uniformity
 
If I have a uniformly distributed random number N from 0 to 2^62-1, but is converted to double R=N/(2^62), and don't have access to the original N. Now I want ...
[3 replies] Last: If you do not have access to the original N then you are SOL. Sorry. ... (by Duthomhas)
How to edit and Delete records in a CSV file
 
Hi all, I am working on a program through Xcode, it is supposed to read a file and perform varuous functions. displayMenu, doDisplay, doView, doAdd, doEdit, and...
[17 replies] Last: I suggest you create these methods in courseType: bool readCSV(is... (by dhayden)
exception with loop (1,2)
 
In the following code I get an exception that disappears when I comment out the line: std::cout << "Element at m[" << i << "][" << j << "][" << k << "] = " <...
[24 replies] Last: Personally I'd never create a 3D (or more) vector*, the most I'd do is... (by George P)
6x6 pelmanism game showing symbols
 
Hello, I am a beginner in cpp and I am currently working on a card matching game. The class function for 3x3 works fine and I wanted to replicate the code an...
[5 replies] Last: Using std::shuffle then possibly: #include <iostream> #include <str... (by seeplus)
Can you go over my code please?
 
I am not sure what I did wrong #include <stdio.h> #include <stdlib.h> int main() { int array ; int sum ={0,0,0,0,0,0}; for(int i=0; i ...
[4 replies] Last: You're not seeding the random number generator by calling srand(). Th... (by AbstractionAnon)
Help with simplifying int main ( ) for Tic Tac Toe Program
 
I'm currently taking a beginner C++ course and finished a lab assignment a couple weeks ago (so it has already be turned in and graded). My professor asked tha...
[3 replies] Last: Perhaps something like (not tried): bool process(char board , char... (by seeplus)
Call objects by integer?
 
I have to create a program where I track types and amounts of candy. I have 4 types of candy that can be called with integers 1-4. When those are called their o...
[2 replies] Last: Line 38: C++ does not support implied left hand side in conditionals.... (by AbstractionAnon)
by frek
Max counters
 
Task description: You are given N counters, initially set to 0, and you have two possible operations on them: increase(X) − counter X is increased by 1, ma...
[7 replies] Last: you read correctly, but what I mean is that you don't know what's a co... (by ne555)
save a 2D array in .mat file
 
Hello everybody. I have a source program in C++ that produces a two dimensional array. Is there a way to save the result in a .mat file that can be opened in ma...
[7 replies] Last: Why can't you use the mat-file interface functions to produce the file... (by seeplus)
Student Grades and Records Problem
 
The problems of my concerns regarding the code below are the ff: 1. There is always having a logical error in computing for the average of the students 2. ...
[2 replies] Last: Perhaps something like this: #include <iostream> using namespace s... (by seeplus)
having trouble using a private helper function
 
Hi, I am using a private helper function that takes one char parameter, and searches an array to see if any index matches the char key. However, I think I am do...
[1 reply] : You are trying to compare an Object (whatever that is) with a char. Ho... (by lastchance)
by frek
Getting started using Catch2 in Visual Studio
 
Hi all, I'm using Visual Studio 2022 (version 17.1.1-community version) on my Windows 10 x64 machine and have just recently installed Catch2 for my IDE. I'm abo...
[13 replies] Last: [quote=George P]What you've mentioned here in this thread does give me... (by MikeyBoy)
code outputing hex values, expecting int/float
 
The code below is to test characteristics of a pointer array. It only has output in hex. I was expecting int/float or anything other than hex. What does it have...
[5 replies] Last: An xy problem, lipstick on a pig, or dreaded waste polishing? #incl... (by againtry)
Problems in Show the player(s) who got the min and max average
 
Hello. This is a sequel to the question that I posted recently. I'm working on the system and I have trouble showing the player(s) who got the max average and m...
[3 replies] Last: With the way I've re-factored it, you don't use option 6 (file open) a... (by seeplus)
Horse race program is giving error. Need help to run this program. I included all the 3 class files and the main files in it.
 
#include "Horserun.cpp" #include "Random.cpp" Horse::Horse(std::string _name) :name(_name) ,distance_covered(0) { } void Horse::run() { // inc...
[7 replies] Last: Your header files should be .h files. Or .hpp files (or whatever ex... (by seeplus)
March 2022 Pages: 12345... 7
  Archived months: [feb2022] [apr2022]

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