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
answer31
viewsHow to read and print an entire word in C++
Well, I did this little c++ program for college. Now I don’t know how read on terminal and then print, there in the function prints, a whole word! Until then I was using the library <string>…
-
-1
votes1
answer37
viewshangman game in C++
Hi guys. I have a problem regarding a specific part of the game, which is already complete. The only problem is the condition I put to check if the word was completely guessed. My code: if…
-
-1
votes2
answers56
viewsOverload of error operator
The code below is with the following error: Error: [Error] invalid operands of types 'Ponteiro*' and 'Ponteiro*' to binary 'operator+' Code: #include <iostream> using namespace std; class…
-
-1
votes1
answer55
viewsGood afternoon, I needed help with a c++ calculator
I made this program to calculate areas and perimeters of geometric shapes, but when I press "a", "b" or "c" to choose whether you want to make areas or perimeters the program just closes. Follows…
c++asked 3 years, 5 months ago Carlos Martins 1 -
-1
votes1
answer67
viewsWhy doesn’t my code make sense?
In my code, I have three "Cin" s that would be three questions to the user, for training of ifs. In this case, at the end we have if((cadastro == 1) && ((ativo == 1) || (logado == 1))){…
-
-1
votes1
answer24
viewsFunction of concatenating two chained lists returning only one element
I have a function that receives as parameter two chained lists containing elements and a third empty list that at the end will be the junction of the two, but at the end of the execution of the…
-
-1
votes1
answer50
viewsHow to identify permutations in matrix columns in C++
In college, I need to do an exercise --- the statement is low --- in which they test with matrices of different dimensions, that is, I need to do a program that reads matrix and writes the matrix…
-
-1
votes1
answer89
viewsHow to write a simple chained list in C++ without using <list>?
I’m using the operator delete to release an allocated memory block via new, however, when executing the code by the terminal it seems not to perform. No code error, it simply does not execute on the…
-
-1
votes0
answers28
viewsSegmentation fault (conversion to post-fixed notation)
The idea of the code is to convert a numerical expression to post-fixed notation (reverse polish), but I cannot run because it gives the error: Segmentation fault (core dumped) Example: Entry:…
-
-1
votes0
answers22
viewsinvert list recursively
#include <iostream> using namespace std; template <class W> struct nodo { W key; nodo<W> *next; nodo(W x) { key = x; next = 0; } }; template <class T> class lsord { private:…
-
-1
votes2
answers44
viewsUse the class to add the object itself into a vector that stays in another object
In python I made the following code: class Escola: def __init__( self, escola_nome ): self.escola_nome = escola_nome self.alunos = [] class Aluno: def __init__( self, nome ): self.nome = nome…
-
-1
votes1
answer30
viewsVector C++ printing garbage
Save it guys. I’m building a C++ cache simulator for a college job. While I was building and testing the code, I came across this mistake. The idea was for the user to set the number of addresses of…
-
-2
votes1
answer1169
viewsHow to use the C++ "strcpy" and "strcat"?
How to use the strcpy and the strcat to take the names of the txt files in a directory inside the application in a folder called value.
-
-2
votes1
answer4125
viewsCalculate distance between two points in C++ using struct
I’m having a hard time printing the result, but before that it’s not realized because it’s a new type created by struct He doesn’t know because he asks double follows the code #include…
-
-2
votes1
answer89
viewsCalling a class by the value of a member
I wonder how I could check if the id of an inherited class is equal to a value x. Something like: class X { id = 3; }; ... class Y { id = 4; }; I have a variable any x, how could I check if x is…
-
-2
votes1
answer226
viewsHow to solve several errors of this code?
I typed this program from the book that addresses classes and gave error. How to solve? #include <iostream> using namespace std; class Efetua_calculo{ private: double total; double soma;…
-
-2
votes1
answer791
viewserror expected Primary-Expression before ' ' token
Error on line 21. #ifndef __STRING_H__ #define __STRING_H__ #pragma warning(disable: 4786) #include <string> #include <vector> const int MAX_RESP = 4; typedef…
-
-2
votes1
answer2446
viewsFind strings within *.txt files in C
I’m a beginner and I’m dying to do a program and C++ that requires doing two functions. 1) Searching a *.txt file for a specific string; 2) Through some type of index indicate the position of this…
-
-2
votes1
answer88
viewsRepeat until the correct letter is typed
Using the function switch, case 'T' : case 'T' : default: How do I for example the two cases represent a letter each, but if the user chooses a different one then follow by default that will remake…
c++asked 7 years, 10 months ago Diogo Martins 1 -
-2
votes1
answer182
viewsHow to pass data read in a program in c++ as momando in cmd
I would like to know how to read something in a program and pass this reading as a command to cmd, through stdlib or cstdlib library, whatever. The picture shows what I’m trying to do.…
-
-2
votes1
answer488
viewsHow to avoid this error message? "main.cpp:8:16: error: lvalue required as left operand of assignment"
I’m getting the error message: "main.cpp: In Function 'int main()': main.cpp:8:16: error: lvalue required as left operand of assignment (-10))/76=n-1;" In the code snippet below,? #include using…
-
-2
votes1
answer3772
viewsWhere is the error? "system is not declared in this Scope'
I’m supposed to do this https://gyazo.com/ae18e6b29f3ffc73c02f518a73145cc4 I drew this up https://gyazo.com/3729ab0e204f3dc49fff3ec9773155eb But for the most part of 15 years old he won’t let me…
-
-2
votes1
answer107
viewsOverload of Operator in C++
I have the program below: #include <iostream> #include <sstream> namespace std { int bin(int n) { if(n!=0)bin(n/2); if(n!=0)std::cout<<n%2; } } int main() { int n;…
-
-2
votes1
answer139
viewsHttp requests using the C language in windows?
How to make http requests using the C language in windows ? No need to post code, just a good reference is enough for me :) But if anyone has any examples will be of great help ;)
-
-2
votes1
answer46
viewsReading of a String
If I have a string that is: String s = "2123dog"; How can I calculate the first character 2 to transform the next 2 characters into an integer, and 4 to transform the name that is dog? The result…
-
-2
votes1
answer64
viewsMiscalculation
#include <stdio.h> #include <stdlib.h> float dobro_do_maior(float x, float y) { float dobro; if(x > y) { dobro = x * 2; }else{ dobro = y * 2; } return dobro; } void main() { float a,…
-
-2
votes1
answer123
viewsTCP/IP protocol on Linux and Windows
The structure of the TCP/IP protocol may vary from Windows for Linux or even from language to language? the knowledge acquired about TCP/IP in the C++ language can also be taken into account in…
-
-2
votes3
answers99
viewsIf I declare a variable and do not use it in the body of the program, will it compile?
I have a program and left a declared variable, but I did not use in the body of the program.
-
-2
votes1
answer149
viewsI wrote this code in Dev C++, it compiled but does not perform the operation
When I run and type a number it does not multiply, it only displays the message " Price:" and not the multiplication result. #include<stdio.h> main() { int quantidade; double valor;…
-
-2
votes2
answers3763
viewsCount letters and pick initials of the name
The program does not print the first letter of each name. nome[i]=nome[i+1]; I need to make a program that enters the name of the person, tells how many letters A has the name of that person and…
-
-2
votes1
answer104
viewsSyntax error using pointer
int main() { char const* path = "/bla/bla"; struct zip *teste; int *errorp; &teste = *zip_open(path, ZIP_CREATE, errorp); return 0; } It returns this error: main.cpp: In function ‘int main()’:…
-
-2
votes1
answer215
viewsHow to implement the strcpy function without using the c++ <string> library?
I was unable to develop an effective code, since I do not understand the language as I should. It doesn’t leave that part : char *strcopy(char *destination, char *origin)
c++asked 5 years, 3 months ago Luis Gomes 7 -
-2
votes2
answers94
viewsCheck if a number is integer, if not, make the user type again
The idea is to make a program that asks the user a number, check if this number is real positive otherwise, request to type again another number, this process can repeat countless times...…
c++asked 4 years, 7 months ago glaubermlira 53 -
-2
votes1
answer27
viewsProblem with a game program (Rooster game in c++)
I’m trying to develop the game of the rooster in c++, but when I try to compile the program I get the same mistake constantly (I’m still new in this world of programming so I’m not sure where I’m…
-
-2
votes1
answer71
viewsResolve Operation with Set
Question 1 - Consider the set X = {x Z : 1 x 32}. Implement a program in C that performs the following instructions. Create three integer-type vectors of size 12: vector 0[12], vector 1[12] and…
-
-2
votes1
answer54
viewsApplication for marking point!
Good afternoon guys, all right? I’m looking to develop an application here for work. Today where I work, we have corporate employees (they are among all the units of the company). And at the end of…
-
-2
votes1
answer96
viewsHow to optimize the time of this code?
I created the code below to solve the problem Vault, of the 2017 OBI. It works, but in 60% of cases it exceeds the time limit, as I do to optimize it? #include <iostream> #include…
-
-2
votes1
answer49
viewsabstract class error (invalid new-Expression of Abstract) C++
Well I’m with an error in my 3 daughter classes(dvd,games,car) of a mother class calls video rental. I am trying to use the Factory method and generates the error in the new with the following…
-
-2
votes1
answer339
viewsThe difference between the value of a maximum and minimum element of a vector recursively
I made that code : int difrecursivo(int *vetor,int tam){ if(tam == 1) return vetor[0]; else{ int max = vetor[0]; if(max < vetor[tam-1]) max = vetor[tam-1]; int min = vetor[0]; if(min >…
-
-2
votes1
answer45
viewsWhy does pre-decrement generate a problem as an argument of a function? Why does Ex1 not work correctly?
#include <iostream> using namespace std; int fatorial(int num); int main(int argc, char const *argv[]){ cout<< factorial(5); return 0; } int factorial(int num)`{` if(num > 1) { Ex1:…
-
-2
votes2
answers184
viewsI’m having an error in my C program
I am having the following error in row 13 column 39: [Error] invalid conversion from 'char' to 'char*' [-fpermissive] It’s for a college job, I can’t fix the mistake in any way, someone knows what…
-
-2
votes1
answer312
viewsDisplay imaginary vector values with pointer arithmetic
Good afternoon ! I’m doing the following exercise ! -Create a program that contains an integer array containing 5 elements. Using pointer arithmetic only, read this keyboard array and print double…
-
-2
votes1
answer64
viewsC++ PROGRAM JUMPING INPUT
I started studying C++ in college and the teacher asked to make a small script to register 3 people and at the end print the chosen person. I made the script with simple inputs and when I run it…
c++asked 4 years, 6 months ago luis henrique 25 -
-2
votes1
answer104
viewsSegmentation fault when returning to main C++
I am getting this error, I know it is an improper memory access error but I can’t find the error! it finishes running the wayValido(...) and when it will return from the main it crashes and gives…
-
-2
votes3
answers611
viewsCode does not run in C on Vscode
I followed 2 tutorials, installed the Vscode and the compiler Mingw, put all necessary extensions, C/C++ Compiler run, among others. And I put the Mingw path in the PATH of the environment…
-
-2
votes1
answer56
viewsHow to see if a string has numbers
I want to make a program that reads a string and returns "+" in front of all the numbers. Example entree: a 1 2 b 3 exit: a +1 +2 b +3 i did it: #include <iostream> #include <cctype>…
-
-2
votes1
answer58
viewsSwitch from string to int c++
Next, I’m doing a function that receives the date this way "XX/XX/XXXX" but I have to perform checks as day, month, leap year, these things, and I’m using its format in string on account of the…
-
-2
votes1
answer34
viewsC++ - Code problem
most variables work, but "Guess" apparently must be modifiable and has many arguments in its function call. How do I fix it? //header #pragma once class Game { public: Game(); void reset(); void…
c++asked 4 years, 1 month ago Joe Wilson 9 -
-2
votes2
answers185
viewsFraction Sum Program (Class Overload)
Good evening, I have a question in my program of sum of two fractions using overload of classes, in which the program it is always printing the same value, even modifying the parameters of the two…
-
-2
votes1
answer63
viewsInsert Loop in C
I wish to insert an option for the user to type in how many rounds he wants to play against the cpu in this joquenpo game follows my code below, can any c master help me ? thanks #include…