General C++ Programming - April 2021 (Page 7)

Find the average exclude 2 largest and 2 smallest
 
int nValues = {182, 163, 174, 155, 168, 160, 159, 168, 172, 180, 173, 171, 177, 175, 169, 161, 165, 159, 169, 172, 174, 175, 166...
[6 replies] Last: Seeplus, in your call to std::accumulate, shouldn't nsize-2 be nsize-... (by seeplus)
How to establish UDP to pass argv[]
 
Hello, my friends. I want to establish UDP between client and server. On the client-side, I initialize my parameter with the command line, like ./hospitalA 2 10...
[1 reply] : > if ((numbytes = sendto(sockfd, argv , strlen(argv ), 0 So instead, i... (by salem c)
How to construct a adj-matrix
 
#include<stdio.h> #include<string.h> #include <stdlib.h> # define MaxVNum 100 using namespace std; // REF: https://www.youtube.com/watch?v=xfL84Kn72nA t...
[3 replies] Last: Thank you very much! (by James ByeBye)
C++ struct 2 dimensional array
 
i faced a problem when i want to let user store their name, age, favourite word and favourite number, and i would like to store them to txt, then when others ne...
[4 replies] Last: You haven't explained why you think it needs to be a two dimensional a... (by AbstractionAnon)
How to write program that reads a file and prints lines of symbols based on its contents?
 
I'm a beginner and am working on an assignment with the following prompt: "Write a program to read from a file. The file contains pairs of a number and a symbol...
[3 replies] Last: #include <iostream> #include <fstream> using namespace std; struct P... (by lastchance)
Makefile assistance
 
I'm having issue compile with make using a Makefile and g++. I have a simple header and source file for a class along with main. I'm unable to get it to compile...
[2 replies] Last: Would you mind providing an example? Edit: Just did a test run, with ... (by lumbeezl)
Dev - C ++ - doubt in exercise C ++
 
The purpose of this system is to keep collectible items (books, CDs, DVDs and magazines), organized by type. The system should allow recording of common and spe...
[3 replies] Last: For me, it's always easiest to start with the data. Read the assignmen... (by dhayden)
having an issue
 
Working on an assignment for my C++ homework. Writing a loop that calls a function out of main in order to complete it. However, whenever I begin the loop it ju...
[2 replies] Last: Sorry sort of new to this site. Also wow am I dumb. Thanks! (by idkwht2name)
How to construct an adj-list/adj-matrix from a txt file in c++
 
The input file like this (0 12 36.93222330340848) (2 8 785.7766177831124) I want to construct a weighted graph, and implement Dijkstra's Algorithm to find the s...
[2 replies] Last: Thanks for your kindly help (by James ByeBye)
Algorithms with comparator
 
How can I make Coctail Sort with comporator? void CocktailSortTemplate(std::vector<int>& b, int n) { bool swapped = true; int start = 0; in...
[2 replies] Last: if( comp(c[i+1], c ) ) // c[i+1] < c thank (by onetwo123)
Been Having a hard time with arrays
 
Hi guys just want to ask how can I transfer the input in my array in choice 1 to the choice 2 I've been trying it and it is not showing #include <iostream> #...
[6 replies] Last: thankful for you all help but just ignore it anyhow... cout <<... (by seeplus)
How to calculate time complexity of this code?
 
What is the time complexity for my code with showing your steps? I tried to figure it out by doing O(T*(n+n+n)) = O(T*n). Am I correct? And any suggestions to m...
[12 replies] Last: Start at the END of the array. (1) Search BACKWARDS for the largest u... (by lastchance)
by cernet
How to get good at reading code?
 
What are some good (small) git* projects that can be used for learning purposes? It is really difficult to find small projects that: 1. Use modern C++ 2. Are...
[8 replies] Last: Fair enough. Not sure if the constant reference applies more to the in... (by lastchance)
Incorrect result
 
Before I wrote this program with Stooge Sort and means of time was normal. Now I use Cocktail Sort but time is 0 in CodeBlocks (there I have .cpp and .h files) ...
[2 replies] Last: Every experiment you time is sorting already sorted data Thanks!... (by onetwo123)
Recursion-
 
Hello everyone, I'm trying to understand Backtracking Algorithm. As I understand, Backtracking should include Choose, Explore, and Un-Choose. My teacher gave...
[3 replies] Last: In this example, I understand what is base case, choose, explore and ... (by dhayden)
Max value question
 
(Question)Write a C++ program that declares an integer array of size 10, then uses three separate functions, one to do each of the following: Ask user to ent...
[2 replies] Last: [quote=your_tutor]Write a C++ program that declares an integer array o... (by salem c)
CALLBACK EnumChildProc
 
#include <windows.h> #include <iostream> using namespace std; BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) { int id = GetDlgCtrlID(hwnd);...
[4 replies] Last: Thanks for answer, I mean that I will use them every time with changin... (by Hawlong)
The risk of wrapper class usage for std::vector<std::atomic<T> >
 
Dear experts I understand std::vector<std::atomic<T>> is prohibited, but there is wrapper class of std::atomic<T> enables STL vector usage as the below. https...
[4 replies] Last: Dear helios Thank you for your kind reply. Yes, I meant just reading... (by Mitsuru)
how to get a pointer to a struct's function
 
struct X{ int x = 3; int get_x(){return x;} int add_x(int i){return x+i;} }; int main() { X str; int (*fcnPtr)(){&(str.get_x)};//this line does not work...
[3 replies] Last: The C-ish way using function pointers. https://www.newty.de/fpt/callba... (by salem c)
by am2809
What is wrong with my toupper loop?
 
Hi, My program is running good I'm just having trouble with my toupper loop. Every time I run the program, the program fails. Can someone help me figure out ...
[4 replies] Last: main() should return int, not void. It looks like you're trying to ... (by dhayden)
April 2021 Pages: 1... 5678
  Archived months: [mar2021] [may2021]

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