detergentTikiya
And after?
After foo exits, b is gone..but the address is still valid in the heap
Mat
b is destroyed and a will never be changed to b's value
detergentTikiya
b is destroyed and a will never be changed to b's value
Yes b is destroyed. but what matters is the address that is still valid because the heap has not released the memory
Lao
detergentTikiya
But you didn't save this address
Do I really need to? If I know the address(which is same throughout the program) why is there a need to save it
Mat
a needs to know the address, not you
Artöm
Do I really need to? If I know the address(which is same throughout the program) why is there a need to save it
Wtf. Right after the call you lost this address. You don't know it. It's gone
detergentTikiya
a needs to know the address, not you
Of cors, a has the address (which is same throughout the program). I am sorry if I am not able to explain my point well
Artöm
You can't get it outside, cause only b holds it
Artöm
And b is gone
detergentTikiya
Wtf. Right after the call you lost this address. You don't know it. It's gone
Wait...I will gdb and double check the addresses pointed to by a before foo and after foo.
detergentTikiya
If they are same, my point stand valid..right?
Artöm
No
detergentTikiya
Why
Artöm
Or add a lot if debug print
Artöm
Or add a lot if debug print
Like, print b before return and a after call
detergentTikiya
I will get back in some time once I am on PC. Thanks for your time though
Bhupesh
Hey guys how do i test for_each_n in Linux It's showing not a member of 'std'
Pavel
And you need to make sure that your compiler is supporting C++17, and you've enabled it. E.g. for gcc you need to add -std=c++17 flag. https://en.cppreference.com/w/cpp/algorithm/for_each_n
Bhupesh
Yes yes Not working
Bhupesh
My GCC version is 7.4.0
Pavel
My GCC version is 7.4.0
I have the same version, let me check
Pavel
My GCC version is 7.4.0
Confirm, I have the same error. Maybe a newer version of compiler is needed
Bhupesh
Yus
Bhupesh
But it's not working even in online compilers 🤔
Mat
Can i see the snippet of the code?
Mihail
Some C++17 things were added as recently as 9.1
Mihail
Don't expect something as old as 7.4 to work well with C++17
Pavel
But it's not working even in online compilers 🤔
Yes, just found out that if you press "Run this code" on this page it will show the same error https://en.cppreference.com/w/cpp/algorithm/for_each_n
Mihail
You really should build yourself a gcc toolchain, because that's very outdated
Mihail
Or install a better distro ( ͡° ͜ʖ ͡°)
Pavel
Nah, I pretty satisfied with it. The compiler supports most of the C++17 features that I need.
ramesh
Hi
μ2x1
https://stackoverflow.com/questions/46468114/for-each-n-is-not-a-member-of-std-in-c17
kappa
How to take multiple input of integer type in single row
Otumian
Yeah.. Just use space to separate them
Otumian
Cool
Anonymous
Hi
Anonymous
I have a question
Otumian
Ask... 423 members are online
Anonymous
Can someone help? I'm confuse with the stop command
kλletaa
Anonymous
yes
kλletaa
what are you confused about
kλletaa
returning a value isn't black magic
Otumian
😂
Otumian
Can someone help? I'm confuse with the stop command
The stop is a flag.. When the input from the user is stop, you'd print some text and maybe quit the program or something.. In all I am sure the stop is a flag.. ❤
Anonymous
If you uncomment 18 line and pass it in foo you don't need malloc at 7 line
Anonymous
I have probably misunderstood your question...
Jussi
I have probably misunderstood your question...
He does not ubderstand that realloc does not allocate memory from the given address, but it actually changes the address
Jussi
Hence a != b after realloc
Anonymous
foo gets a copy of a
Anonymous
Not 'a' itself in that example
Ravi
What is x86 or 64 bit
Artöm
What is x86 or 64 bit
Size of machine word. Only thing you definitely should know: it affects sizeof pointer and sizeof size_t
klimi
ramesh
Hlo
Anonymous
Hello
Anonymous
Hii
Anonymous
#include <stdio.h> void main() { char s[1000]; int count = 0,i = 0; printf("Enter a sentence\n"); scanf("%[^\n]s", s); while (i < s[i]) { if (s[i] != ' ') { s[count] = s[i]; count++; } i++; } printf("Length of semtence excluding space is %d", I want to print the number of character in sentence excluding space And using while loop and without using #include<string.h> What should i do further to print the number of character?