Most voted "c++" questions
C++ is a typed, compiled, multi-paradigm, intermediate level, and general purpose programming language. It should not be confused with the language C. It was developed in the early 1980s by Bjarne Stroustrup as an extension of C. Its evolutionary features include type checking, support for automatic resource management, object orientation, generic programming and treatment of exceptions, among others.
Learn more…2,348 questions
Sort by count of
-
1
votes1
answer175
viewsDynamic allocation giving problem in c++
Have this problem to solve in Hacker Rank and my code for the solution of this problem was as follows: #include <cmath> #include <cstdio> #include <vector> #include…
-
1
votes1
answer45
viewsSyntax inside a struct that looks like a function
I was analyzing a code in C++ and came across the following structure: struct ligacao { int v_; int w_; int ComEXp; ligacao(int v, int w, int ComEXp1) : v_(v), w_(w), ComEXp(ComEXp1) {} // Minha…
-
1
votes1
answer505
viewsMemory allocation error for multiple files "terminate called after Throwing an instance of 'Std::bad_alloc' what(): Std::bad_alloc" [C++]
I’m using a sorting algorithm for a digital voice signal processing project. This algorithm was developed to receive all audio signals in a single vector to do the processing, but I’m having…
c++ allocation memory-management multiple-file-upload memory-limitasked 4 years, 4 months ago Marcus Vinicius De Paula 21 -
1
votes1
answer1610
viewsmanipulate csv file in c++
I need to read a cvs file with the following fields: Id,OwnerUserId,CreationDate,Score,Title,Body Id inteiro OwerUserID inteiro Data vou armazerna como char Score inteiro Title texto Body texto…
c++asked 6 years, 8 months ago Andre Luiz 115 -
1
votes1
answer15
viewsHelp with c++ vectors
I need to create a program where give the lowest value and tell what position you are in, example input: 4 5,4,3,1 exit: lower value : 1 position: 4 so far my code is like this and I have no idea…
-
1
votes1
answer2029
viewsError "No match for Operator <<" in C++
I made this code but I have no idea why this error : "No match for 'Operator <<' In the part where I display the user’s reply... (Remembering that Namemouth is a class and Date is also...)…
-
1
votes0
answers46
viewsGet the Start Address from a process thread and finish it individually
What I want to do is open up to check if a process is open, see the thread list, identify it by Start Address, and finish a process-specific thread. I can do it manually by the processhacker, but I…
-
1
votes1
answer665
viewsDifference in char* and const char* at the beginning of a function in C
const char* lerArquivo(FILE *file, int tam, char *path){ file = fopen(path, "r"); int cont; char *palavra; for(cont = 0; cont < tam; cont++){ fscanf(file, "%c", &palavra[cont]); palavra[cont…
-
1
votes1
answer64
viewsVector return problem in c++
I’m trying to make a little program to sort vector and I’m using a helper function to do this, but it’s turning me on to this error message. /media/isaque/dados/exercicios/c/scripts/estrutura de…
-
1
votes1
answer56
viewsWhat is the purpose of the symbol "&" in the declaration of an object?
I noticed that some statements of variables/objects are used * for the statement (thus generating a pointer), but in some cases has the statement using &. const MyClass & my_class =…
-
1
votes1
answer30
viewsProblems with C/C++ Struct Array
I’m trying to make a program that reads a string and int and stores its values in one struct and then print it on the screen, I’m still learning, forgive me if it’s a very obvious mistake. Code:…
-
1
votes1
answer72
viewsHow to check if the function would generate an Exit in C++
I have a .lib with some functions. I defined that when the calculation of some function generates values outside the range allowed it to exit(). Now my C++ code that uses this lib need to calculate…
-
1
votes1
answer592
viewsI wonder what’s wrong with my code?
My code is a question, I’m learning to program and using the site codcad, the question is in the image. When I send my code, it only gives 60 points of 100. I wonder what I’m doing wrong. Follow the…
c++asked 6 years, 7 months ago Prometheus 97 -
1
votes2
answers77
viewsWhen to use constexpr in C++?
See you around the keyword constexpr (mainly in ifs and constants) many times, I have read the Microsoft documentation and searched on the internet and still did not understand much the function of…
-
1
votes2
answers75
viewsHow do I define Operator= for a c++ struct?
I have the structure to follow: struct PATH { vector<ARCO_TEMPO> rota; set<int> rotaAux; float COST; int nArcosVoyage; vector<bool> VisitedNodes; vector<vector<bool>>…
-
1
votes1
answer99
viewsMemory pointer and allocation
I know which pointer stores memory address. And a variable stores a value. But taking into account that I have a class class player {} and create a variable player p; and an instance of a pointer…
-
1
votes2
answers80
viewsUse extra space in addition to that reserved by "malloc"
When we request an amount of memory from the system and use much more than requested, what happens? I did this test and the code here compiled normally. At first it worked as it should, I wanted to…
-
1
votes1
answer180
viewsHow to pass a double pointer as argument and return it from C++ function
I have a function I need her to be void and that a Double Pole be returned from her by the argument. void cracking::decompose(char input[][100], int size_S, double* &Atm, int* &ID, int…
-
1
votes1
answer38
viewscontainer comparison
the following code works well -> std::vector<int> vec = { 1, 2, 3, 4, 5 }; std::vector<int> mec = { 1, 2, 3, 4, 5 }; if (vec == mec) { std::cout << "true" << std::endl; }…
c++asked 6 years, 7 months ago Strawberry Swing 177 -
1
votes1
answer57
viewsLetter to lowercase conversion gives a numerical result
Which part of this code C++ I’m missing where I need to convert a whole word to lowercase? #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string>…
-
1
votes1
answer37
viewsWhen I type withdrawal and place the amount higher than the balance the if is not working and barring this operation
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> std::string nome, menu; float saldo, valor, saque; using namespace std; main() { std::cout…
c++asked 6 years, 7 months ago Vitor Ernandes 11 -
1
votes1
answer41
viewsget directory
I would like to know how to add the name of the user where it is in quotes written "I must put the name of the user here" #include "stdafx.h" #include<iostream> #include<Windows.h>…
-
1
votes0
answers20
viewsWhat are the members' initialization lists and under what circumstances should they be used?
What is the purpose of a member initialization list that is used in class/struct constructors in the C++ language and under what circumstances it should be used.
-
1
votes1
answer172
viewsHow to access elements of a vector of a type defined by struct?
In my code, I made the following statement of struct: struct material { int idmaterial; double rho; double precokg; }; I wanted to run this function, which reads data from a file:…
-
1
votes0
answers49
viewsWhy is there an error coming at the end of a file that ends with blank spaces in a while loop, using the >>read operator?
I want to perform a reading function of a "material" vector (I created this type with "struct"). The reading will be executed from a file. std::vector<material> material_read(std::string s) {…
-
1
votes1
answer38
viewsHow to limit a value entered/modified by the memory address?
To limit a value that has been entered/changed by the memory address? PS: I can not limit by function, this function is just an example function showing the problem, I will need to pass this object…
-
1
votes1
answer502
viewsCreate/manipulate file within a directory other than main.cpp
This works, creates a file and puts what I want inside it: #include <fstream> #include <vector> using namespace std; int main() { ofstream arquivo; arquivo.open("arquivo.txt");…
c++asked 6 years, 6 months ago MiguelTeixeira 60 -
1
votes1
answer31
viewsStrange character in place of the directory
When I run this code in the place where it was supposed to appear the directory appears Ó²o formula.exe, someone could help me solve ? #include <iostream> #include <Windows.h> #include…
-
1
votes0
answers47
viewsShould I really use getters and setters for all public variables in the classes?
So this subject seems very controversial but at the same time I don’t see a call among developers. Some say that getters and setters are 100% rule to access any variable within a class. That is, if…
-
1
votes0
answers69
viewsHow should a dynamic recompilation work?
Sometimes reading about emulation and even developing my own emulators is inevitable not to come across the subject. Basically there are two types of emulation, by means of dynamic interpretation or…
-
1
votes1
answer31
viewsvector inside vector generates double values in the second dimension
In the example below (which can also be seen in Ideone), I have a vector of a class and within the class I have an element too vector. The point is that by doing the push_back class, the internal…
-
1
votes1
answer69
viewsDeclare array in class not knowing it will be its size
How to declare an array within a class, even if you don’t know what size it will be and leave it accessible throughout the program. Note this class: class exemplo{ public: int tx{0}; int ty{0}; int…
-
1
votes1
answer79
viewsWhat is wrong in the double variable
I need to make an algorithm that the user informs two values and return the biggest among them using double, but when compiling it from the error pointing something in double but do not know how to…
-
1
votes1
answer96
viewsError using Opengl GTX GLM library
I’m trying to compile in linux Ubuntu a project that uses the quaternions for rotation of 3D objects of the glui library, when I compile the code the system accuses the following error : Code says…
-
1
votes0
answers171
views3D cylinder with 2D lines in Opengl
How to calculate a matrix of 3D points that form a 3D cylinder and draw the cylinder using 2D lines (connecting the points of the Matrix and forming a mesh of the representation of the 3D object)?…
-
1
votes2
answers47
viewsProblem when replacing strings
Hi, I’m starting to create an equation interpreter, I want to replace the operators with words, but things aren’t going well... main.cpp #include <string> #include <iostream> #include…
-
1
votes1
answer178
viewsTake the result of an expression in c++
I’m almost done with my expression interpreter. But I have no idea how to do the most important part : The result I’d learn a lot from any idea. main.cpp #include <string> #include…
-
1
votes0
answers16
viewsProblem running main components
Hello, I’m running an algorithm for sorting objects in an image. At the present moment I need to determine the coordinates of the center of the obejto to calculate the diameter and apply…
-
1
votes1
answer1012
viewsHow to optimize this code (Time Limit Exceeded)?
This code is a possible solution to the 1211 problem in the URI Online Judge. On my pc runs normal for the test cases, but on the platform I get the message from Time Limit Exceeded. Any…
c++asked 6 years, 4 months ago Isabela Almeida 11 -
1
votes0
answers91
viewsOpencv - C++ - Raspberry Pi
I want the function to check all the time if there is a fingerprint. If there is, I want you to start the capture scheme in sequence (the for nested), but the function I created is not working that…
-
1
votes1
answer108
viewsC code, url=inet_ntoa(*(struct in_addr *)ip->h_addr); I don’t understand what’s going on
I was studying sockets for this stuff https://www.exploit-db.com/papers/13634/ and I came across a code that I don’t understand what’s going on. That’s the part of the code: struct hostent *ip; ...…
-
1
votes0
answers69
viewsDistribution addicted when using the Rand() function
Hello, how do I use the function rand() with the range Y [11, height+9] and X [11, width-1]. srand (time(NULL)); y=rand() % ((altura+9)-11) + 11; x=rand() % ((largura-1)-11) + 11; gotoXY(x, y);…
-
1
votes1
answer861
viewsPassing array as a function parameter
How to pass a array to a function without me having to inform the amount of indexes it has? Stating the size #include "stdafx.h" #include <Windows.h> void imprimir(int _array[], int _tamanho)…
-
1
votes1
answer35
viewsProblem with a string attribute of an object
Hello! I’m having a problem with a member of the string type of my object. When I do the object.word assignment = "some word", the program even compiles and runs, but when I print the content, it…
-
1
votes2
answers522
viewsInfinite loop on switch
The problem is that in all three cases, cout repeats endlessly. #include<iostream> using namespace std; #include<locale.h> int main(){ setlocale(LC_ALL, "Portuguese"); bool a; int…
-
1
votes1
answer72
viewsPoint-to-point operation on image
I am trying to perform a simple sum operation that adds 30 to the intensities on each channel, but the program only hangs without error output (probably some type error). I hit that reply //…
-
1
votes1
answer103
viewsBinary tree printing only left side
Hello. My binary tree is printing only the left side, what can it be? I am using TAD to implement. Tree structure: typedef struct _no { int conteudo; struct _no *esquerda; struct _no *direita;…
-
1
votes1
answer279
viewsDijkstra Algorithm - How do I change the reading of the txt file in C to be identified in int and not string?
Good night, I’m having a question how to change the reading of the txt file, where the compiler identifies with char but within the file that need read, possessed only numbers, someone could help me…
-
1
votes1
answer85
viewsDoing BMI calculations I’m not getting just the result 80
#include <stdio.h> #include <math.h> int main() { float peso,altura,imc; imc=0; printf("digite seu peso ?"); scanf("%f",&peso); printf("digite sua altura? ");…
-
1
votes0
answers187
viewsProgram does not run both For links within if - C
I have 2 ties for within a if, as shown below: if (grid[j][k] == words[i][0]){ int el = j, col = k; //Metodo direita, baixo for(l=0;l < wordlen(search_word);l++){ if(l%2 != 0 ){ // Procura à…