Linked Questions

0 votes
1 answer
198 views

I'm trying to compare two class objects, which has both been initialized with 0.0, but for some reason C++ decides to convert the 0.0 to some extremly small value instead of keeping the 0.0, which ...
Exchange_programming's user avatar
1 vote
3 answers
80 views

The core idea of this is just to have a array of integers and change the value of them based on teminal inputs. This is my very first project and everything seems to be in order but it does not work, ...
DrSolidDevil's user avatar
-3 votes
1 answer
277 views

so the 3rd function calls on the read_integer(prompt) from the int read_integer(string prompt) above it, seen by the ***** marks, but I am not sure what to add so that this works. My attempt in the ...
user7171717's user avatar
0 votes
1 answer
94 views

The following code will segfault. char* input = "12.34"; //< this is only to simplify the example. char buffer[30] = { 0 }; memcpy(buffer, input, strlen(input)); char* part1 = strsep(&buffer,...
gberthiaume's user avatar
0 votes
0 answers
55 views

I'm using raylib to make a little game. and here is the problem. Struct Icon has Loc Struct that has two integer value. When i put the Struct, Icon as a Pointer into Icons vector. value has been ...
Roharui's user avatar
  • 100
0 votes
0 answers
46 views

#include <iostream> using namespace std; string userInput, userName; The function below takes an input from the user string takeInput() { cin.ignore(); getline(cin,...
cat lat's user avatar
  • 37
145 votes
12 answers
55k views

I'm told that the template system in C++ is Turing-complete at compile time. This is mentioned in this post and also on wikipedia. Can you provide a nontrivial example of a computation that exploits ...
Federico A. Ramponi's user avatar
6 votes
2 answers
4k views

I have a vector: std::vector<int> vec = {1, 2, 3}; And I want to make a reverse for loop. It works, when I write: for(int i = vec.size() - 1; i >= 0; --i) { std::cout << i << ...
asd's user avatar
  • 266
4 votes
8 answers
207 views

I am trying to printf a simple string but I am not being able to. #include <stdio.h> int main(){ char *word; scanf("%s", &word); printf("%s\n", word); return ...
Miguel Matos's user avatar
14 votes
1 answer
531 views

Sayeth the C++ standard: The point of declaration for a name is immediately after its complete declarator and before its initializer (if any)... [basic.scope.pdecl] That is, a variable is in scope, ...
Sneftel's user avatar
  • 41.9k
7 votes
2 answers
159 views

#include<stdio.h> void main(){ printf("%f\n",5/9); // prints 0.000000 printf("%f\n",9.0/5.0); // prints 1.800000 printf("%f\n",5/9); // prints 1.799999 } ...
Jim Stone's user avatar
4 votes
3 answers
339 views

considering this code snippet #include <iostream> int foo() { int a; return a; } int main() { auto &&ret = std::move(foo()); std::cout << ret; } compile with ASAN g++ -...
codesavesworld's user avatar
2 votes
1 answer
5k views

clang, but NOT gcc, has a -Weverything option which appears to include things such as -Wpedantic. You can test it here: https://godbolt.org/z/qcYKd1. See the top-right of the window for where I have ...
Gabriel Staples's user avatar
2 votes
2 answers
1k views

I know that, if we declare variables inside a function without allocating memory for them, they will be lost after the function finishes its job. The following code prints: (null) 5 char* ...
No N's user avatar
  • 159
2 votes
3 answers
2k views

can you help me with this code, i am able to copy arr into arr2(from index 1 and further, i cannot figure index 0 till now), but some others can't. Can you tell if anything's wrong here? #include <...
Aroosh Rana's user avatar

15 30 50 per page
1
2 3 4 5
18