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
-
2
votes1
answer1154
viewsVectors - Separate negative and positive
I have to make a program that receives a vector of 8 numbers and returns 2 vectors, the first with the positive numbers of the vector of 8 positions, and the second with the negative numbers. THE…
-
2
votes2
answers512
viewsError creating child - Process scheduling using Fork
Write a program in C/C++ called novel.cpp that does the following: The Father process creates a Filho1 process in 10 seconds and a Filho2 process in 20 seconds and then you’re running indefinitely.…
-
2
votes1
answer1127
viewsAll possible paths in graphs
I am doing a work that part of it consists of finding all possible paths from one vertex to another given vertex, for this I am using an algorithm almost identical to DFS as shown below: #include…
-
2
votes1
answer1101
viewsMaximum possible size to allocate a vector
Guys, I have a data structure project that’s meant to analyze search algorithms on the largest possible vector that my machine can allocate. Can someone help me figure out how to create a vector of…
-
2
votes1
answer56
viewsHow to save in a single vector, base and derivative classes?
I have a work in C++, and I need to write to a single vector, a base class, and two derivatives. How to do this vector?
-
2
votes1
answer511
viewslvalue required as left operand of assignment - rest of division
I’m having a problem making rest of the division. Gave that mistake: value required as left operand of assignment How do I fix it? #include <stdio.h> #include <stdlib.h> int main() { int…
-
2
votes1
answer14650
viewsI want to know how to limit the decimal place to c++ using Std
So I’m doing a simple program and I wanted to know how to limit the decimal place in the input, putting Cin and taking only 1 houses, for example I type 2.6534 and the program only takes 2.6. Could…
c++asked 6 years, 7 months ago Prometheus 97 -
2
votes2
answers473
viewsRegular expressions C++
I have a text with the following formatting Concept:personasia:toby_pizur:personasia:test How do I get a string with this format, only the text after the last two points(:) ? In the example above, I…
-
2
votes2
answers340
viewsRefection return in C++
I cannot understand what the following function returns. int * begin(){ // return &this->data[0]; } Does this function return the address of a reference? I didn’t understand it very well.…
-
2
votes2
answers15220
viewsHow to clear the screen in C++?
How to clear the screen in C++ ? I already put the library: ** #include< stdlib. h>** and the code: system("cls"), but gives the error: "sh: 1: cls: not found". How do I fix this?…
-
2
votes2
answers455
viewsCalculate memory address by pointer arithmetic
Suppose the elements of the vector v are of the type int and each int takes 8 bytes on your computer. If the address of v[0] is 55000, what is the value of the expression v + 3?…
-
2
votes1
answer91
viewsLinked List - append and push
I’m trying to learn Linked List and I made the following code: #include <iostream> using namespace std; typedef struct snode { int data; snode *next; } node; void start(node ** head) {…
-
2
votes0
answers433
viewsWhat is the difference between . h and . hpp and when to use (C++)
Files . h are used in C/C++ as header files where all their contents are automatically passed to another file. cpp and your choice using the command: #include <arquivo.h> But recently I saw a…
-
2
votes3
answers1443
viewsC++ - How to create a window in windows
I’m starting to program for windows using c++ and the Devc++ program. How do I create a common window?
-
2
votes1
answer245
viewsHow do I add a value to a struct vector, for example in some vector field, because it is from a struct
#include <iostream> #include <vector> using namespace std; struct dados { int pessoas; int consumo; }; int main() { int totalx=0, totaly=0; int n,x,y; vector<dados> info; //int…
-
2
votes2
answers1619
viewsAbout headers in C++
Some doubts have arisen specifically about the creation of headers: If I create a test file. h, and another test.cpp, as the C++ compiler does to relate the test.cpp file to the test file. h, that…
-
2
votes1
answer92
viewsFunction with variable number of parameters via template
I know that templates in function definitions do, for each configuration it makes possible, compile a distinct function. I want to know if it is possible to create functions of varied number of…
-
2
votes1
answer69
viewsAdd method to an existing c++ class
I wonder if in c++ you can increment an existing class by inserting new methods, without touching the class source code directly. For example, if the class below is part of an external library that…
-
2
votes1
answer208
viewsHow to declare a multidimensional array using new
How do I declare a multidimensional array using new ? A normal array would look like this: int* ponteiro = new int[5]; But int* ponteiro = new int[5][5]; does not compile ! but int array[5][5];…
-
2
votes1
answer35
viewsHow to compile C++ in Visualstudio using linux inside windows
A friend said he has how to do this compilation by Visualstudio and run in a linux "subsystem"
-
2
votes2
answers136
viewsWhat is the difference between memcpy and snprintf
I see people using snprintf when I would use memcpy. I even did some tests and it worked with memcpy. Now I was in doubt of why to use one and not the other. And what the real meaning of the two.…
-
2
votes1
answer73
views -
2
votes2
answers1633
viewsDoubt in a simple c++ ENCRYPTION program
I have a question about implementing an encryption code. Follow the code below: #include <iostream> using namespace std; int main(int argc, char** argv) { string criptografar(string mensagem);…
c++asked 7 years, 2 months ago Gustavo de Souza 21 -
2
votes0
answers129
viewsQuestions related to an anti Cheat system
I have not found a better way to describe the title of the topic, if it is not good enough, I ask that moderation edit it for me. I have some questions related to an effective anti Cheat system for…
-
2
votes1
answer620
viewsOperator overload in C++
I’m learning operator overload. For this I am testing to overload the * operator so that it is interpreted as | string class object * variable type int = string class object concatenated with it so…
-
2
votes1
answer51
viewsprogram does not catch system date
I have a program that I am doing a test to see how it goes but I could not find the error that makes it does not return the date and time of the system, I thought it was the regex but it is also not…
-
2
votes1
answer323
viewsHow to copy an array of struct to an equal one?
I have 2 arrays made of a struct: struct events { string Kind; int Time; int DurVal; int Chan; }; events e1[100] events e2[100]; How can I make a full copy of the array e1 for e2 in a single…
-
2
votes1
answer163
viewsHow to use Emscripten?
I wanted to convert my codes into C++ for Javascript so I could use them on web pages. How can I do this? From what I’ve researched Emscripten does that, I just don’t know how to use it. How it…
-
2
votes1
answer75
views -
2
votes2
answers90
viewsWhy can normal functions not have "auto" arguments if "lambda Expressions" can in C++?
I realized that the "lambda Expressions" accept arguments of the type auto. For example: auto add = [](const auto& x, const auto& y) { return x + y; } So I tried normal functions, but it…
-
2
votes2
answers130
viewssplit an integer number into c++
I made the following program below that guess the age of the person and the number that she thought, but the final result generates a number of 4 digits according to the calculations below suppose I…
-
2
votes1
answer826
viewsHow to configure the amount of exponent numbers in scientific notation in C++
My code is giving the error in the presentation of the scientific number, because it always appears with 3 decimal places being necessary only. #include <stdio.h> int main(){ float num=0.0;…
-
2
votes1
answer273
viewsUsing the switch function in C++
The function switch and I don’t know what I’m doing wrong marcos there appear "landmarks and cool" and put murilo "Nice and cool". I’m doing it like this: #include <stdio.h> #include…
-
2
votes1
answer1082
viewsCompile C++ file in VS Code using external cmd
I can compile files in VS Code normally, but the files are shown in the terminal of the program, which does not allow the insertion of characters. How can I set up to be able to use a terminal that…
-
2
votes2
answers255
viewsPossibility challenge in c,c++ or Matlab
I’m in need of a program that gives me the possibilities of the following equation: x*y = 1700/57 Whereas x and y are positive reals resulting from two integers ("a" and "b") different from 1 to…
-
2
votes1
answer63
viewsDifference of calling a function in Dllmain by Createthread or calling directly
What is the difference of calling a function in the following ways: The first way creating a thread. Example: DWORD WINAPI Metodo1(LPVOID) { // Meu código aqui... return NULL; } int WINAPI…
-
2
votes3
answers161
viewsSize of a character array according to its addressing
Is the size of a character array given by its address or by the value of the variable? Example: char[1000] = "Exemplo Teste" The size of this variable is 1KB due to its addressing char[1000] or her…
-
2
votes3
answers606
views -
2
votes2
answers167
viewsThe whole name doesn’t appear
In C language as I can show the whole name when asked to enter the user name, I think it is not correct the definition of the char, my code is this: int main(int argc, char** argv) { char nome[100];…
-
2
votes2
answers55
viewsCan you add the keyword "noexcept" in get/set methods?
Is there any problem in adding to keyword noexcept in methods getters/setters of a class that only returns or changes values of simple variables (bool, int, float, double, etc..)?…
-
2
votes1
answer245
viewsWhat is the purpose of using pointers and allocation in c/c++
I would like to understand what pointers are in a generic way and their use, I see simpler codes as registration that I myself do in codeblocks run smoothly without them. Similarly I’m doubtful…
-
2
votes1
answer200
views -
2
votes2
answers2032
views -
2
votes2
answers1132
viewsChange compiler settings in Codeblocks
I will participate in a clear programming and need to configure the compiler, in the case of Codeblocks, in the following ways: C: GCC compiler version 8.2 or higher - Command line: gcc -lm -O2…
-
2
votes1
answer221
viewsHow to use a class array as a pointer?
How do I use a class array as a pointer? I tried several ways, but C++ didn’t let you compile by generating errors. An example of class(It’s just one example, the class I need to use is thousands of…
-
2
votes0
answers109
viewsProblems with Opencv in Qt Creator
Program shows no error when build, but when running the code it displays the following message: libopencv_core.so. 3.4: cannot open Shared Object file: No such file or directory the file . pro is…
-
2
votes0
answers56
viewsActivating cgi bin web c++ module
Personal I installed cgicc for the purpose of understanding how cgi works however I activated the include mod_cgi of my apache2 in Slackware but when creating a cgi and put in /var/www/cgi-bin the…
-
2
votes1
answer147
viewsDetect and change System() error message
I have a question about the use of function system. For example, if we execute the following command: (system""); If the example command is not found on the system the function prints the following…
-
2
votes0
answers250
viewsHelp with bicubic interpolation algorithm
I’m trying to implement the bicubic interpolation algorithm but I’m having a lot of difficulty with the correct interpolated values( is not related to taking the values of the original matrix but…
-
2
votes1
answer95
viewsC++ language standard for pointer
I’m starting studies on C++ would like what is the language recommendation (market standard) to reference a pointer. ex: l->propriedade; or (*l).propriedade; I believe there’s no difference in…