python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Why did I write the declaration into the main function that the program does not run
When I write the following three lines of code into the main function, the program will not run.
const int N = 500005;
long long a[N]={0};
long long b[N]={0};
At first, I thought it was a problem wit...
Sophia912
Votes: 0
Answers: 1
Is char* created with "..." and new are on stack and heap respectively? Just want a brief answer if my understanding is right or wrong?
const char* s1 = "John";
const char* s2 = new char[] {"Cena"};
// is s1 on stack?
// is s2 on heap?
...
// use s1 and s2
...
delete s1;
// do I need to delete s1?
delete[] s2?
//...
hklsb
Votes: 0
Answers: 1
Ternary operator in a for loop
So I have the following code:
#include <stdio.h>
int f(char *c)
{
static int i=0;
for (;*c;*c++=='a'?i--:i++);
return i;
}
int main()
{
for(int i=1; i<4; i++)
printf(...
ign0r
Votes: 0
Answers: 1
Segementation fault whilst trying to deep copy struct
I have this piece of code, where I have an array of Constituencies and I wish to deep copy the whole array into a new array. Now too me, it seems I'm doing this correctly but I keep getting a segmenta...
Daniel
Votes: 0
Answers: 1