Anonymous
and what would that look for "signed" big-endian?
Anonymous
and what would that look for "signed" big-endian?
Learn ways how signed numbers can be represented in memory
Anonymous
#include<bits/stdc++.h> using namespace std; struct p{ int x : 1; int y : 2; }; int main(){ struct p a; cout<<a.x<<" "<<a.y<<endl; return 0; }
Anonymous
Output : -1 0
Anonymous
❓what does int x : 1 do?
Jussi
❓what does int x : 1 do?
https://en.wikipedia.org/wiki/C_syntax#Bit_fields
Anonymous
It says unsigned int flag : 1; makes "flag as a one bit field"
Anonymous
so it means flag can either be 0 or 1. Right?
Jussi
yes. its size will be 1 bit.
Anonymous
but what would then be its default value?
Jussi
it is not defined
Anonymous
I mean what is struct_object.flag equals to?
Anonymous
so in my case int x : 1 means x is one bit field.
Anonymous
Then why did a.x give -1?
Anonymous
how does a.x appears in memory?
Dima
Anonymous
Well, I am learning.
Anonymous
for int x:2; what happens to rest 2 bytes?
Jussi
how does a.x appears in memory?
most likely it will be a 32/64bit registry, but the software only reads first of it
What's stdc++.h?
a header file that includes every standard library, its good to use in programming contests
Mat
Oh right, now i remember it...
dont use it every where
Mat
dont use it every where
I would never use it 🤷‍♂
Anonymous
and the reason why a.x gives -1?
Anonymous
a.x -1 ??
Mihail
and the reason why a.x gives -1?
Because you didn't initialize it
Ravan
Hi I am a student
I_Interface
Ravan
Thanks
Ravan
I want to learn new things in c++
Ravan
Can u help me
Mihail
Google can
Ahmed
Ravan
cout<<"what ""
Ahmed
cout<<"Hello word!";
Ahmed
yeah . Just type namespace std;
I_Interface
I_Interface
std::cout or "using std::cout" in code block
Ahmed
Depends on VS or workshop you use for programming c++
Dima
this is bad
Dima
use std:: namespaces directly
I_Interface
use std:: namespaces directly
"using std::cout" in code block is also bad ? :(
Anonymous
this is bad
It's bad if it declared globally in headers
Dima
Yeah I don’t think cout name is used much in other libs
Anonymous
If it declared in small scope it's just fine
Anonymous
Of course, if there is no name ambiguity
Anonymous
Am I wrong?
Ahmed
what's a bad idea in that namespace ? A memory leak or a problem would occur in the compiler?
Dima
wait.. is it a serious question?
I_Interface
what's a bad idea in that namespace ? A memory leak or a problem would occur in the compiler?
If using this namespace, it could make a conflict with functions from other libraries
Neutronix
Guys, could someone help me to use libraries? I don't understand how to use it
Anonymous
Observe the following block of code and determine what happens when x=2? switch (x) { case 1: case 2: case 3:cout<<"x is 3, so jumping to third branch"; goto thirdBranch; Default: cout<<"x is not within the range, so need to say Thank You! "; }
Neutronix
Doesn't work #include <directory/namefile>
Neutronix
Ok
Thank you :)
Neutronix
It does
I don't know why but not
Neutronix
Show
I can ghive you my teamviewer
Dima
What the hell
Dima
just post the code
klimi
I can ghive you my teamviewer
Yeah, just show the line
Dima
Please help me
it’s obvious, it will fallthrough with a case 3
Neutronix
just post the code
It's not only 1 file, this library is 8 different files and they are connected
Mat
#howtoask
Neutronix
If I put the directory in one of these after the error is in another one etc
klimi
We cant use telepathy
Neutronix
I take the error also in the library, so i Think who made the libraries is not stupid and there's another system to do it