...
"how to pass ... to C API"
Anonymous
...
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> *> *')
Vishal
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
Apparently noexcept might have performance penalties in some cases.
Dima
is it good motivation:)?
Dima
Anonymous
gotta go to zavod
There are pretty good salaries at some factories actually
Dima
also AI and tech will replace factory workers in the near future ¯\_(ツ)_/¯
Anonymous
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
Nils
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/
Henry
Binesh
/get cbook
_waͣrͬdͩaͣdͩdͩy_
Mohammed
By mistake, damn this fast share options ><
Surbhi
I need java study materials .
Pavel
Anonymous
I need c study material
Pavel
Valeriia🇺🇦
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
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
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
Vishal
The cpu only has to do arithmetic on 2 values right...types are language abstractions on top
Vishal