Questions tagged as 'c++'

1
answer

How to iterate through each character in a std :: istream?

In std::string , the allocation is done like this; in chunks of 128 characters note . It takes each input character and places it by std::string::push_back . How can I do it? Note - link     
asked by 24.05.2014 / 04:54
1
answer

How to declare a multidimensional array using new

How do I declare a multidimensional array using new? A normal array looks like this: int* ponteiro = new int[5]; But int* ponteiro = new int[5][5]; Do not compile! but int array[5][5]; works perfectly.     
asked by 29.05.2018 / 19:30
1
answer

Maximum size possible to allocate a vector

Folks, I have a data structure project that is used to analyze search algorithms in the largest possible vector that my machine can allocate. Can anyone help me figure out how to create a vector of maximum size? The language is C ++     
asked by 14.03.2018 / 17:29
1
answer

How to set the number 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 needed only. #include <stdio.h> int main(){ float num=0.0; scanf("%f",&num); printf("%.4e",...
asked by 05.09.2018 / 20:23
1
answer

Allocate memory with pointer or reference?

Are there any significant differences between these two methods? MyClass &ref = (*(new MyClass)); MyClass *ptr = (new MyClass);     
asked by 11.09.2018 / 12:17
1
answer

Snake game, try a beginner C / C ++

Hello, I'm doing the snake game, but I'm doing with an array, the way I'm doing is giving prints and system ("cls") quickly, but I'd like to know more efficient ways, like for example the gotoxy Code to give print to screen: int i, j; cout<...
asked by 02.08.2018 / 13:23
2
answers

The whole name does not appear

In C language as I can show the whole name when you are asked to enter the user name, I think the char definition is not correct, my code is this: int main(int argc, char** argv) { char nome[100]; fflush(stdin); int idade;// para garantir que...
asked by 06.11.2017 / 23:52
1
answer

Add method to an existing c ++ class

I would like to know if in c ++ you can increment an existing class by inserting new methods, without directly manipulating the source code of the class. For example, if the class below is part of an external library that should not be change...
asked by 20.05.2018 / 01:07
2
answers

C Cast vs C ++ Cast

What is the difference between using the cast of C: float t = 5.0f; int v = (int)t; For the C ++ cast: float t = 5.0f; int v = static_cast<int>(t);     
asked by 06.10.2017 / 14:34
1
answer

Difference between std :: map, std :: unordered_map, std :: flat_map, and which one to choose?

What is the difference between library functions map , unordered_map , flat_map , and which one to use, for example in terms of performance?     
asked by 23.12.2017 / 02:23