...
"how to pass ... to C API"
...
Nothing, it wouldn't compile Casting std::array to c-array is bad
also, yes it would, but it would compile to the exact same code, https://godbolt.org/z/YYGhGd
...
so, what else would you do in this case
Dima
Safe Danya
Anonymous
Afaik POD term is deprecated
Pavel
Hm, have read about is_pod and can't understand the difference between is_trivial and is_standard_layout (and between these two and is_pod)
Danny
Helo
Pavel
good one, thanks :)
Nils
Hi, whats wrong: const std::vector<std::string> hints = {...}; std::vector<std::string>::iterator *hintPointer = hints.begin(); // error: no viable conversion from 'std::__2::vector<std::__2::basic_string<char>, std::__2::allocator<std::__2::basic_string<char> > >::const_iterator' (aka '__wrap_iter<const std::__2::basic_string<char> *>') to 'std::vector<std::string>::const_iterator *' (aka '__wrap_iter<const std::__2::basic_string<char> *> *')
Nils
I think you need to remove * from hintpointer
calling a private constructor of class 'std::__2::__wrap_iter<const std::__2::basic_string<char> *>'
Vishal
begin () returns an iterator
Vishal
You've got pointer to the iterator
Nils
error: calling a private constructor of class 'std::__2::__wrap_iter<const std::__2::basic_string<char> *>' hintPointer = &hints[1];
Nils
Then how can I get the iterator of the 2nd element in a vector?
Nils
okay, thx… That was simple.
Vishal
Hello all, I recently read that char, signed char and unsigned char are 3 different types. I had always thought that char will always be one of the other 2.. what is a char then?
Vishal
Got it..thanks
Vishal
Perfomance should increase
youtube.com/watch?v=dVRLp-Rwg0k
Vishal
Apparently noexcept might have performance penalties in some cases.
Dima
How to motivate myself to learn coding
you’ll die or suffer without a proper job, so get used to it and get some motivation with coffee and start working
Dima
is it good motivation:)?
Anonymous
How to motivate myself to learn coding
This is you if you don't get a well paid job I took the photo now Such a beautiful Russian Federation
Anonymous
gotta go to zavod
There are pretty good salaries at some factories actually
Dima
There are pretty good salaries at some factories actually
nah it’s better for me to sit infront of my display and write code
Dima
also AI and tech will replace factory workers in the near future ¯\_(ツ)_/¯
Anonymous
nah it’s better for me to sit infront of my display and write code
That's what some people do at factories😂
Anonymous
okay, thx… That was simple.
you can also do hints[1] or hints.begin()[1] not all containers support this, but using an index when supported instead of a pointer/iterator avoids this common undefined behaviour - for(iptr = arr; iptr < size; iptr += 3) (just incrementing a pointer/iterator beyond the past the end position is an undefined behaviour, you don't even need to access it)
Tokin
Lol
Nils
But the vector is guaranteed to be at least 3 elements long
Nils
So that does not matter
Anonymous
@N95maskjghealthcare
_waͣrͬdͩaͣdͩdͩy_
C2x: the future C standard / Badoo / Хабр https://habr.com/en/company/badoo/blog/512802/
Binesh
/get cbook
Anonymous
C2x: the future C standard / Badoo / Хабр https://habr.com/en/company/badoo/blog/512802/
A covid standard... I actually didn't imagined something like that would come in a time like this. But well, there is no better time
Mohammed
By mistake, damn this fast share options ><
Surbhi
I need java study materials .
Pavel
I need java study materials .
Wrong chat, it's C/C++
Anonymous
I need c study material
Valeriia🇺🇦
MTG
/getfreeprogrammingbook
/getfreeprogrammingbook
Anonymous
I am new in C programming Currently on Pointers.. Can anybody please explain how below program output is geeks main( ) { char g[ ] = "geeksforgeeks"; printf("%s", g + g[6] - g[8]); }
Tokin
Is it?
Tokin
Cool
MTG
If anyone has leetcode premium can you please send the editorial solution explanation for : https://leetcode.com/problems/task-scheduler/
Anonymous
Anyone pls let me know where can I learn stl for c++ freee
Anonymous
I have knowledge of c++ but haven't used STL
Anonymous
Oh
Tokin
And I was trying to figure out the heck is this
Anonymous
Ohkay...understood! Thank you..
Vishal
Undefined behaviour because '\0' is not guaranteed to be at the end or due to some other reason?
Vishal
I think string constants are null terminated..so that shouldn't be the reason..so why exactly is it undefined behaviour without the brackets?
MTG
I am new in C programming Currently on Pointers.. Can anybody please explain how below program output is geeks main( ) { char g[ ] = "geeksforgeeks"; printf("%s", g + g[6] - g[8]); }
It is because of the pointer arithmetic. When you perform arithmetic operation on a character, the operation actually happens on the ascii value of the character. So g[6] - g[8] gets evaluated to 8 that is (111 - 103) So g + 8 tells the compiler that : print from the 8th location starting from g, until you encounter a '\0' (NULL) character.
MTG
And it is not a undefined behavior because when you assign a string literal to character array '\0' will get appended automatically.
Vishal
But as long as you don't access that memory location how is it UB?
MTG
No it will not be undefined behavior I think
MTG
Do you have any output of the undefined behavior?
.
/notes
.
#goodcodingmentality
Vishal
That's strange
MTG
The memory address will not be passed to the printf until the computation is done
MTG
g + 100 - 100 // is this a undefined behavior ?
MTG
No can u share the part standard which are referring to
MTG
It is said that you can't access the memory location which is out of bounds, not that u can perform arithmetic on that
MTG
It will matter
MTG
the final computed address should not go out of bounds
Vishal
I don't understand how pointer arithmetic differs from normal arithmetic
Vishal
The cpu isn't aware I thought
MTG
it can
MTG
I don't understand how pointer arithmetic differs from normal arithmetic
the only difference is that if u do + 1 it's not actually + 1 its the next memory address depending on type + 2 is next of next .. so on..
Vishal
The cpu only has to do arithmetic on 2 values right...types are language abstractions on top
Vishal
the only difference is that if u do + 1 it's not actually + 1 its the next memory address depending on type + 2 is next of next .. so on..
Yeah because in case of pointers the 2nd value which will be passed will not be 1 but the size of pointer