Jump to content

Programming interest unna vaallu itu randi!!!!!


Recommended Posts

Posted

[quote author=ChittiNaidu link=topic=127624.msg1411236#msg1411236 date=1291163595]
  Katrina KAif Sonia Gandhi Role vestunte.....Parliament lo Sonia ni chusi Katrina ni oohinchukune face nuvvu nu....[img]http://s5.tinypic.com/30wsgpf_th.jpg[/img]

akkada seppindi PRogramming gurinchi....
[/quote]


@3$% @3$% @3$%

  • Replies 199
  • Created
  • Last Reply

Top Posters In This Topic

  • krldr871

    34

  • dkchinnari

    31

  • chipanjichiru

    27

  • andhrabalayya

    22

Posted

[quote author=Leader871 link=topic=127624.msg1411255#msg1411255 date=1291163856]
nenu cheppindi ahde kadhaa [img]http://s5.tinypic.com/30wsgpf_th.jpg[/img]
[/quote]

sSc_hiding2 sSc_hiding2 sSc_hiding2

Posted

[quote author=dkchinnari link=topic=127624.msg1411259#msg1411259 date=1291163891]
nu adiganadaniniki answer enti baa...
[/quote]
segmentation fault vastadi baa..we r trying to access some random address n trying to print the value of 4 bytes from the starting address

Posted

[quote author=dkchinnari link=topic=127624.msg1411259#msg1411259 date=1291163891]
nu adiganadaniniki answer enti baa...
[/quote]

You will get compilation error.

Posted

[quote author=Leader871 link=topic=127624.msg1411237#msg1411237 date=1291163620]
Ok one more interesting problem..

int a=5;

printf("%lld",*(long *)(&a));

printf("%ld",*(long *)(&a));
[/quote]
chitti gaa answer disssss  *7*^ *7*^ *7*^ *7*^

Posted

[quote author=TollywoodEmperor link=topic=127624.msg1411278#msg1411278 date=1291164096]
You will get compilation error.
[/quote]
compile time issue kadu adi..run time lo vastadi..it will compile with a warning..

Posted

[quote author=Leader871 link=topic=127624.msg1411281#msg1411281 date=1291164136]
compile time issue kadu adi..run time lo vastadi..it will compile with a warning..
[/quote]
@gr33d

Posted

umm...Now, on all common 32 bit OSes, long and int are the same size, so the second line is likely to print 5. On many 64 bit OS'es, however, long is larger than int, so the second line may print garbage, and is undefined behavior. The first line is wrong on all OS'es. If a long is larger than an int, then in practice you will usually get a long value where half of it is 5 and the other half is garbage. One problem is that the %lld format specifier is for a long long, and you are passing it a long. The second problem is that &a points to an int, and you cast it to a long and then dereference it, which is undefined.

[quote author=Leader871 link=topic=127624.msg1411237#msg1411237 date=1291163620]
Ok one more interesting problem..

int a=5;

printf("%lld",*(long *)(&a));

printf("%ld",*(long *)(&a));
[/quote]

Posted

[quote author=Leader871 link=topic=127624.msg1411280#msg1411280 date=1291164108]
chitti gaa answer disssss  *7*^ *7*^ *7*^ *7*^
[/quote]

frst erroe and next one some address value garbage

Posted

[quote author=Leader871 link=topic=127624.msg1411281#msg1411281 date=1291164136]
compile time issue kadu adi..run time lo vastadi..it will compile with a warning..
[/quote]

@gr33d @gr33d @gr33d

Posted

[quote author=andhrabalayya link=topic=127624.msg1411291#msg1411291 date=1291164436]
umm...Now, on all common 32 bit OSes, long and int are the same size, so the second line is likely to print 5. On many 64 bit OS'es, however, long is larger than int, so the second line may print garbage, and is undefined behavior. The first line is wrong on all OS'es. If a long is larger than an int, then in practice you will usually get a long value where half of it is 5 and the other half is garbage. One problem is that the %lld format specifier is for a long long, and you are passing it a long. The second problem is that &a points to an int, and you cast it to a long and then dereference it, which is undefined.
[/quote]
well actually %lld is sufficient and i dont have to cast it to a long..
printf(%lld",p);

it would try to print out 8 bytes from that p's starting address..

Posted

[quote author=andhrabalayya link=topic=127624.msg1411291#msg1411291 date=1291164436]
umm...Now, on all common 32 bit OSes, long and int are the same size, so the second line is likely to print 5. On many 64 bit OS'es, however, long is larger than int, so the second line may print garbage, and is undefined behavior. The first line is wrong on all OS'es. If a long is larger than an int, then in practice you will usually get a long value where half of it is 5 and the other half is garbage. One problem is that the %lld format specifier is for a long long, and you are passing it a long. The second problem is that &a points to an int, and you cast it to a long and then dereference it, which is undefined.
[/quote]


Yup i am also thinking same in second one...First one lo %lld ante yemiti?

Posted

[quote author=ChittiNaidu link=topic=127624.msg1411294#msg1411294 date=1291164488]
sCo_hmmthink sCo_hmmthink

no videa baa....

guess cheyamnte...my guess will be first output error vastundi..Long Long Data Type ki, second di 5 anukunta...
[/quote]
error kadu..warning vastadi obviously 1st daniki..
%lld ante long long..usually long long size is bigger than that of an int..so aa p ki sambandinchina 4 bytes kakunda inkoka 4 bytes..motham 8 bytes lo unde value print avutundi..assuming long long is 8 bytes lng

Posted

[quote author=Leader871 link=topic=127624.msg1411326#msg1411326 date=1291164824]
error kadu..warning vastadi obviously 1st daniki..
%lld ante long long..usually long long size is bigger than that of an int..so aa p ki sambandinchina 4 bytes kakunda inkoka 4 bytes..motham 8 bytes lo unde value print avutundi..assuming long long is 8 bytes lng
[/quote]

second daniki 5 print avuthundha?

i can write that statement as follows:  long *p; p=&a;
*p=?    p is address of a...When we dereference it , we get storage value = 5;

Posted

[quote author=dkchinnari link=topic=127624.msg1411302#msg1411302 date=1291164564]
frst erroe and next one some address value garbage
[/quote]
mama garbage ante enti..it is quite common to find this term in basic textbooks..at least nenu first chadivinappudu garbage ante ento ankunevaadini..
lets say u declare a variable and dont initialize it..assuming it is a local variable..stack lo memory allocate avthadi..aa particular address lo previous ga unna value alane untadi andulo..so print cheste neku kavaalsina or expctd value raadu..or inka neat ga cheppalante evadoo vaadesina memory ni nuvvu unchukuntunav..so garbage ani antaaru..
andhrabalayya correct me if im wrong  sSc_hiding2 sSc_hiding2

×
×
  • Create New...