#includestdio.h
#includeconio.h
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit={1,2,2};
printf(%d %d %d\n,bit.bit1,bit.bit3,bit.bit4);
getche();
return 0;
}
the above code gives output : -1 2 2
any idea why???
--
You
I think it is because bit1 is only 1 bit fwide and whn u initialize it to
1,since MSB is 1 it treats it as a negative integer...Plz correct me if i am
wrong...
On Tue, Aug 9, 2011 at 12:24 PM, Rohit Srivastava access2ro...@gmail.comwrote:
#includestdio.h
#includeconio.h
int main()
{
Int bit3:4 will be read as lower order 4 bits of bit3 and this will be
treated as int (signed). Thus lower order bit of bit3 which is 2, are
0010 which is 2
try with
1) int bit3:2, output will be -2
2) unsigned int bit3:2, output will be 2.
I hope it is cleared now
On 8/9/11, Rohit Srivastava
hey guys thanks got it!!
On Tue, Aug 9, 2011 at 12:49 PM, sanjay ahuja sanjayahuja.i...@gmail.comwrote:
Int bit3:4 will be read as lower order 4 bits of bit3 and this will be
treated as int (signed). Thus lower order bit of bit3 which is 2, are
0010 which is 2
try with
1) int bit3:2,
On a little-endian machine, bit structure will be represented as:
0x00 00 00 45
which is bit.bit4 = 0010 (2 in decimal) bit.bit3 = 0010 (2 in decimal)
bit.bit1 = 1 (1 in decimal)
since bit.bit1 exists at the rightmost position, while displaying data as
integer, compiler just repeats the same
i dnt get it.. any better explanation..
On Tue, Aug 9, 2011 at 1:13 PM, dinesh bansal bansal...@gmail.com wrote:
On a little-endian machine, bit structure will be represented as:
0x00 00 00 45
which is bit.bit4 = 0010 (2 in decimal) bit.bit3 = 0010 (2 in decimal)
bit.bit1 = 1 (1 in
#includestdio.h
int main()
{
typedef static int *i;
static int j;
i a = j;
printf(%d, *a);
getchar();
return 0;
}
what is the error in the code?
--
Regards,
Kamakshi
kamakshi...@gmail.com
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
using typedef u define the static keyword as int
and the statement static int j thus becomes
int int j
hence the compiler gives the error multiple storage class in declaration
specifiers
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Mon, Aug 8, 2011
typedef doesn't declare an instance of a variable, it declares a type (type
alias actually),
static is a qualifier you apply to an instance, not a type, so you can use
static when you use the type, but not when you define the type.
Aseem
On Mon, Aug 8, 2011 at 12:29 AM, Kamakshii Aggarwal
got it...thanks
On Mon, Aug 8, 2011 at 12:39 AM, aseem garg ase.as...@gmail.com wrote:
typedef doesn't declare an instance of a variable, it declares a type (type
alias actually),
static is a qualifier you apply to an instance, not a type, so you can use
static when you use the type, but
int b=2;b=b++;
b=???
Plz explain..
Aseem
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
3.it is same as b=b+1;
On Sun, Jul 31, 2011 at 1:32 AM, aseem garg ase.as...@gmail.com wrote:
int b=2;b=b++;
b=???
Plz explain..
Aseem
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@Kamakshi: Run karke dekh leti pehle. :-/
Aseem
On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
3.it is same as b=b+1;
On Sun, Jul 31, 2011 at 1:32 AM, aseem garg ase.as...@gmail.com wrote:
int b=2;b=b++;
b=???
Plz explain..
Aseem
--
You received
it would be undefined...
On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
3.it is same as b=b+1;
On Sun, Jul 31, 2011 at 1:32 AM, aseem garg ase.as...@gmail.com wrote:
int b=2;b=b++;
b=???
Plz explain..
Aseem
--
You received this message because you
oh sorry,mane galat pad lia..mane sirf b++ dekha...
it is compiler dependent.value of b is changing twice b/w two serial points
On Sun, Jul 31, 2011 at 1:37 AM, aseem garg ase.as...@gmail.com wrote:
@Kamakshi: Run karke dekh leti pehle. :-/
Aseem
On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii
@Aditi: Run karke dekh leti pehle. :-/
Aseem
On Sun, Jul 31, 2011 at 1:38 AM, aditi garg aditi.garg.6...@gmail.comwrote:
it would be undefined...
On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.com
wrote:
3.it is same as b=b+1;
On Sun, Jul 31, 2011 at 1:32 AM,
concept of sequence points.search wiki
On Sun, Jul 31, 2011 at 1:38 AM, aditi garg aditi.garg.6...@gmail.comwrote:
it would be undefined...
On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.com
wrote:
3.it is same as b=b+1;
On Sun, Jul 31, 2011 at 1:32 AM, aseem
@aseem output is 3 only...check it once again
http://ideone.com/mWGc5
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Sun, Jul 31, 2011 at 1:37 AM, aseem garg ase.as...@gmail.com wrote:
@Kamakshi: Run karke dekh leti pehle. :-/
Aseem
On Sun,
@aseem its 3
different on yours ?
On Sun, Jul 31, 2011 at 1:37 AM, aseem garg ase.as...@gmail.com wrote:
@Kamakshi: Run karke dekh leti pehle. :-/
Aseem
On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.com
wrote:
3.it is same as b=b+1;
On Sun, Jul 31, 2011 at
Yes, it's UB.
For such ques, try to run it on ideone.
It will give a warning if any operation is not standard.
http://ideone.com/bJBGl
http://ideone.com/bJBGl
On Sun, Jul 31, 2011 at 1:38 AM, aditi garg aditi.garg.6...@gmail.comwrote:
it would be undefined...
On Sun, Jul 31, 2011 at 1:34
I am getting 2. .
Aseem
On Sun, Jul 31, 2011 at 1:41 AM, Neeraj Gupta neeraj.gupta...@gmail.comwrote:
Yes, it's UB.
For such ques, try to run it on ideone.
It will give a warning if any operation is not standard.
http://ideone.com/bJBGl
http://ideone.com/bJBGl
On Sun, Jul 31, 2011 at
On Dev CPP.
Aseem
On Sun, Jul 31, 2011 at 1:42 AM, aseem garg ase.as...@gmail.com wrote:
I am getting 2. .
Aseem
On Sun, Jul 31, 2011 at 1:41 AM, Neeraj Gupta
neeraj.gupta...@gmail.comwrote:
Yes, it's UB.
For such ques, try to run it on ideone.
It will give a warning if any
yup it is undefined and the warning is justified
b=b++ will assign 2 to b then increment b hence 3 is printed
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Sun, Jul 31, 2011 at 1:41 AM, Neeraj Gupta neeraj.gupta...@gmail.comwrote:
Yes, it's UB.
For
I am getting b=2.
Maybe coz we are assigning 2 to b then incrementing b. But still acc to me
it should be 3.
:-\
No warnings in dev cpp.
On Sun, Jul 31, 2011 at 1:43 AM, Amol Sharma amolsharm...@gmail.com wrote:
yup it is undefined and the warning is justified
b=b++ will assign 2 to b then
@sanchit:it is undefined..
On Sun, Jul 31, 2011 at 1:47 AM, Sanchit Manchanda sanchit...@gmail.comwrote:
I am getting b=2.
Maybe coz we are assigning 2 to b then incrementing b. But still acc to me
it should be 3.
:-\
No warnings in dev cpp.
On Sun, Jul 31, 2011 at 1:43 AM, Amol Sharma
I dint get any error, not even warning. it might depend from compiler to
compiler. but yeah it should be undefined.
On Sun, Jul 31, 2011 at 1:49 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
@sanchit:it is undefined..
On Sun, Jul 31, 2011 at 1:47 AM, Sanchit Manchanda
bt y it sud b undefind?
On Sun, Jul 31, 2011 at 1:51 AM, Sanchit Manchanda sanchit...@gmail.comwrote:
I dint get any error, not even warning. it might depend from compiler to
compiler. but yeah it should be undefined.
On Sun, Jul 31, 2011 at 1:49 AM, Kamakshii Aggarwal kamakshi...@gmail.com
@gaurav:refer the link below
http://c-faq.com/expr/seqpoints.html
On Sun, Jul 31, 2011 at 1:53 AM, gaurav gupta grvgupta...@gmail.com wrote:
bt y it sud b undefind?
On Sun, Jul 31, 2011 at 1:51 AM, Sanchit Manchanda
sanchit...@gmail.comwrote:
I dint get any error, not even warning. it
thanx kamakshi
On Sun, Jul 31, 2011 at 1:56 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
@gaurav:refer the link below
http://c-faq.com/expr/seqpoints.html
On Sun, Jul 31, 2011 at 1:53 AM, gaurav gupta grvgupta...@gmail.comwrote:
bt y it sud b undefind?
On Sun, Jul 31, 2011 at
29 matches
Mail list logo