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
answer65
viewsMemory leak in Return
I’m reading a book and I came across this code: class SimpleCat { public: SimpleCat (int age, int weight); ~SimpleCat() {} int GetAge() { return itsAge; } int GetWeight() { return itsWeight; }…
-
-1
votes1
answer110
viewsFile location txt Android ndk / C++
I made a c++ code to create a file: I’ve already given the manifest permission to read and record: My question is:???…
-
-1
votes1
answer146
viewsProgram does not execute when filling vector with non-repeated random numbers in C
I’m trying to get random numbers to be generated and fill in a vector in a separate function, but the program doesn’t run and crash if I put a high number, and not as high as 50 or 100. Below…
-
-1
votes1
answer55
viewsProgram with 3 files
I made a code in c++ that works if it’s all inside the main.cpp. When I create other files, like a header it from the indefinite reference error. I have done everything and only managed to make it…
-
-1
votes1
answer225
viewsError in client-server connection via socket
I’m a beginner in c++ and I’m having trouble getting my client code to establish a connection with my server in Python, the server is working, but the client always enter error 4 and does not…
-
-1
votes1
answer654
viewsRandom numbers in c++ without repetition
I need to do a program that generates N numbers without repetition between a set of 1 to 600000 numbers. the values of N are 50000,10000,50000,100000 and 500000. These numbers will be stored in a…
c++asked 6 years, 7 months ago Andre Luiz 115 -
-1
votes1
answer190
viewsRead a txt file and store content in lists
I need to read a large ". txt" file and its contents are in the following format: 1 12 1 13 2 5 2 6 I would like to know if it is possible to read the value of each column and store it in a list,…
-
-1
votes2
answers88
viewsIs it possible to view all the content of a C++ namespace?
When you make the directive: using namespace std; //primeira forma You get direct access to all elements of the Std namespace. But imagine that you want to use only the std::cout or std::endl so it…
-
-1
votes1
answer514
viewsHow to rename a program process in C C++ (Windows Lib)
I am creating a utility program for windows but can’t change the name that appears in task manager, I have tried SetConsoleTitle("atwconnect"); but changed only the window name but not the process…
-
-1
votes1
answer805
viewsCopy string to struct
While trying to copy String nome into String in Struct novo->nome the program stops working if I comment on the function strcpy(novo->nome,nome); the code is executed normally. //Função de…
-
-1
votes1
answer97
viewshow do I resolve this exercise in c/c++
at the end I still need to print which stores are presenting a price within the media, someone help me; #include<bits/stdc++.h> struct difsites{ double preco; char loja[50]; char site[50]; };…
-
-1
votes1
answer871
views -
-1
votes2
answers253
viewscopy an entire txt file to a c++ string
Is there any function that copies a txt file to disk and transfers it whole to a string, without copying character by character in c++?
c++asked 6 years, 4 months ago Andre Luiz 115 -
-1
votes1
answer119
viewsI’m not able to use libcurl C++
Guys, I can’t get my libcurl on! Could someone give me a hand? teach me how to compile this correctly! Because I am following all the steps that come in a doc together with the project itself.…
-
-1
votes1
answer215
viewsShuffle list in c++
I want to know how I can, given a list, shuffle the order of the elements in it. The type structure of the list I want to shuffle is as follows. struct exemplo { int I; int O; int V; struct exemplo…
-
-1
votes1
answer1163
viewsHow to put sound in c++?
I’m still new with programming and wanted to put the sound of Super Mario inside a college project, as I do so it can work? Code: int certo=0,errado=0,certoVF=0,certoA=0; char…
-
-1
votes2
answers701
viewsHow do I use %d or %c... in Cout instruction?
I am studying C and C++ and would like to understand how I could transform this code written with printf() in cout, or how to use the functions %d %x %c, etc. in the cout. int main() { printf("i…
-
-1
votes2
answers511
viewsInsert Image and music into a c++ project
Hello, which library allows me to insert images and music in a c++ project? Does the SDL2 library allow? Right now I have the Snake game running only on the console, but I would like to put a…
c++asked 6 years, 3 months ago Fábio Morais 1,522 -
-1
votes1
answer1260
viewsRead char and string in c++
I have to put an integer, a real, a character and a sentence containing spaces up to 100 characters. I tried to make the solution but, I can only type the numbers and it is not leaving the character…
-
-1
votes1
answer702
viewsCheck that stack 1 elements are equal to stack 2, C++
You guys, good night! I need to do this part of the code in C++ comparing whether the elements on Stack 1 are the same as on Stack 2 and whether the amount of elements are exactly the same. I don’t…
-
-1
votes1
answer25
viewsErrors: Division by zero and iterator not dereferencable
I’m having trouble compiling this code, it returns me two errors while running it: vector<bool> cp( size ); // determine crossover point (randomly) for( int i = _numberOfCrossoverPoints; i…
-
-1
votes1
answer110
viewsUsing static or dynamic variables in my codes? What would be more efficient or better seen in the job market?
What’s better: Using static or dynamic variables (using pointers in the case) in my codes? What would be more efficient or better seen in the labour market? I imagine that each one has its most…
-
-1
votes1
answer39
viewsYou are running the direct commands with no time to type the other notes
You’re not letting me type the rest, just typing the first one goes to the last one. #include <iostream> #include<stdio.h> int main(void) { int n1,n2,pim,rn1,rn2,rpim,rfinal; rn1=n1*4;…
-
-1
votes1
answer124
viewsRandom Boolean Matrix in C++
good afternoon. I need to develop a Boolean matrix (almost a graph) random in C++, but I confess I used a lot of python, so I’m having a hard time getting started. But the focus of the question is,…
-
-1
votes1
answer35
viewsgoto unsafe variable value
I’m making a simple code and I’m using the goto #include <iostream> using namespace std; int exemplo(void); int main() { exemplo(); } exemplo(){ comeco: { int numero; numero = 0; goto fim; }…
c++asked 5 years, 8 months ago Darius da costa 303 -
-1
votes1
answer141
viewsHow do I concatenate a string without using the functions of the string library?
#include <stdio.h> void concatenar (char str1, char str2){ int c, a; for(c=0; str1[c]!='0'; c++) for(a=0; str2[a]!='0'; a++){ str1[c]=str2[a]; } return str1; } int main (void){ char str1[10],…
-
-1
votes2
answers144
viewsOperation of function scanf()
Can anyone explain to me how the function scanf() works? Not the basic, but how does the mechanism it has to return the number of arguments that were read. To whom does it return? Why does it…
-
-1
votes1
answer82
viewsPython versus C++
Hi, I’m a novice programmer. I wrote a program for processing images in Python that worked perfectly, although its execution is very slow, due to the large number of operations involved. I decided…
-
-1
votes1
answer113
viewsIdentify multiple numbers in a variable
Create a program that given a set of temperatures of 8 Portuguese cities, identified by an order number, indicate which have a temperature above the country average. My problem is identifying these…
-
-1
votes1
answer68
viewsRadix-Sort method does not work properly!
[.cpp has to measure and average the processing time of the implementation methods] After implementing the Radix all stopped timing the time correctly. The program asks how many numbers and how many…
-
-1
votes3
answers477
viewsHow to account for the number of primes in a matrix?
I’m inserting random numbers into a matriz[10][5], where within it I count the quantity only of prime numbers. But I’m having difficulty extracting with the counter only the prime numbers. int…
c++asked 5 years, 6 months ago Matheus Vargas 1 -
-1
votes1
answer200
viewsC++ libraries
my problem is this: my college activity is to create a program in which the user can move the cursor from the screen to where he wants, using coordinates, and also the user can change the color of…
-
-1
votes1
answer110
viewsWhile with logical operator "or" - C++
I’m having trouble finishing an algorithm. When you insert a loop while In order not to allow an invalid form to be entered, the code shows an error in execution. If someone helps me by giving me…
c++asked 5 years, 4 months ago Rafael Bennington 1 -
-1
votes1
answer129
viewsHelp to get struct values(Arduino,C++)
I am developing an application with esp32 (similar to Arduino) that gets date and time from an NTP server. Use the following function to display these values: void printLocalTime() { struct tm…
-
-1
votes2
answers538
viewsCodeblocks compiles (linux operating system Mint) but does not show on screen
People installed Codeblocks on Linux Mint and so it opens perfectly you make the program it compiles beauty (If you have errors it shows), however, it does not open the interactive screen (sorry for…
-
-1
votes1
answer76
viewsImplementing function of type Month
Good morning guys blz? was implementing a Month type function that returns Month I tried to use static_cast to convert to Month type but from conversion errors to same. The program is this below:…
-
-1
votes1
answer28
viewsFunction return -0
I created a polynomial class, among the member functions present in my class is the root resolution function. If the degree of the polynomial is 2, I use baskhara for resolution. But I realized that…
-
-1
votes1
answer67
viewsSublime Text does not work properly
I installed Sublime Text on my linux. I opened the test.cpp file that contains the following code: #include <iostream> using namespace std; int main() { cout << "Hello World!" <<…
-
-1
votes1
answer1327
viewsHow to convert String to Int in C++
I’m not able to convert this simple program. how do you convert? #include <string.h> #include <stdlib.h> using namespace std; int main () { int i; string a; i = atol (a); } . Error…
-
-1
votes1
answer250
viewsValidating only cpfs with different numbers
Good evening guys needed to do in the function below a way to invalidate typed cpfs with equal numbers by ex: 123456789 000000000 111111111 222222222222 333333333 444444444 555555555 666666666…
-
-1
votes1
answer28
viewsIn the string transp, it was to appear all 4 names, however, only the last one appears
#include <iostream> using namespace std; void texto(); void soma(int n1, int n2); int soma2(int n1, int n2); void tr(string tra[4]); int main(){ int res; string…
c++asked 6 years, 9 months ago Duduh Henrique 1 -
-1
votes2
answers225
viewsHow to initialize a string vector within a struct?
I need to start a list with names of people at the beginning of my program and I am trying to initialize the names in a string within my struct, that way: char* nomes[100] = {"gabriel" , "vanessa"};…
-
-1
votes1
answer286
viewsC/C++ libraries and preprocessing
I’ve always wondered the syntax of #include and of #define, as they differ greatly from the syntax of the rest of the language. I found that this is because these commands are intended for the…
-
-1
votes1
answer179
viewsSending a C++ vector to a Python function
I have the following function written in python in a file. py: def coordinate(arg): print arg return True And an example of C++ code in a file. CPP #include <Python.h> #include <vector>…
-
-1
votes1
answer25
viewsI’m having an error in my c++ exercise. What can I do to fix it?
#include <math.h> #include <iomanip> #include <iostream> using namespace std; int main() { float R; float pi = 3.14159; float volume = (4.0 / 3) * pi * pow(R, 3); cin >> R;…
c++asked 4 years, 1 month ago Rhama Krisner 11 -
-1
votes1
answer56
viewsIn the vector category pair<string, int>: When adding a new string, check whether a future string has the same value as an already added string
And if so, change the value of the previously added pair instead of adding a new pair. So, I’d like to add string pairs, int into an array, only, to avoid redundant pairs, check if the string…
-
-1
votes1
answer31
viewsthis algorithm is to verify divisor
this algorithm is to check if the first is splitter of the second and at the end show whether it is splitter or not splitter, no error, but do not know how to continue #include <stdio. h>…
-
-1
votes1
answer42
viewsLibraries in C++
I have a question about the C++ libraries that are hammering me in time. Is it really necessary to import for example the Math. h library to use functions like Pow and sqrt? or the locale library. h…
c++asked 3 years, 9 months ago MICHEL LEMOS 45 -
-1
votes1
answer33
viewsI am trying to compare the word deposit with what the user will type, and if it is equal he will make the deposit
#include <stdio.h> #include <stdlib.h> #include <math.h> char nome[45], menu[45]; float saldo, valor; main(){ printf("Digite seu nome \n"); scanf("%s", &nome); printf("Digite o…
-
-1
votes1
answer22
viewsI cannot access any class outside the same script. C++ IDE: Unity 2019.4.29f1
EX: Enemy: public class Inimigo : MonoBehaviour { public static int ContadorInimigo; public Inimigo() { ContadorInimigo++; } } The second script already Gamecontroll: void start() { Inimigo inimigo1…