please look into this and respond

sumit kumar <sumit_india1998-/[email protected]> Thu, 29 Dec 2005 06:04:05 -0800 (PST)
Newsgroups gmane.comp.lang.c.general,gmane.comp.programming.cppug
Message-ID <[email protected]>
  Please Refer Bottem Post....
   
  > > Hi geeks,
> > can any body give me the code for the following
> > void main()
> > {
> >   int i=5;
> >   change();
> >   i=10;
> >   printf("%d", i);
> > }  // end of main
> > write something in change() function only, such that after executing the
> > program it should print 5 but not 10;
> > i know the method but i dont know how to implement it,
> > HINT: here we have increment the program counter.

  > This problem demonstrates havocs that may be caused by Buffer Overrun.
> void change() {
>      long a[2];
>      int k;
>      k = 0;
>  l1: k = 1;
>  l2: k = (&&l2 - &&l1);
>      a[3] += k;
> }

  > If you don't initialize  the k to zero and reinitialize it to the 1,
> compiler may not generate the code for the instruction of k=1; but may
> put the 1 at the stack address of k directly. all that is because of
> optimization. And you may fail to find the diff btw the labels.
>
> Check the archieves for the same problem. We had spent a lot of energy
> and bandwidth on this. The only point behind these problems is to
> learn the logic. How variables are used in stacks, and where the
> programs may lead to, if not properly written.
   
   
  Dear All,
  If this code is run on VC++ it would report an error i.e. :
   
  error C2059: syntax error : '&&'
   
  on unix it works fine, but I dont understand use of "&&" before label name I mean can we extract addresses of labels if yes why VC++ compiler dosen't recognise this. Can any of us elaborate more on this. So the picture becomes more clear, If you refer to some previous post chain please mention dates because finding some perticular information from a whole lot is pretty difficult and would take days. 
   
  Thanks and Regards,
  Sumit Kumar 
  +91-80-30956948
   


		
---------------------------------
 Yahoo! DSL Something to write home about. Just $16.99/mo. or less