Re: [algogeeks] C++ initialization list

2014-09-28 Thread sagar sindwani
Hi Saurabh

Thanks for the document. Please refer to start of page 214, Section 8.5.4
,point 3, Below is example from that

struct S2 {
int m1;
double m2, m3;
};
S2 s21 = { 1, 2, 3.0 };   // OK
S2 s22 { 1.0, 2, 3 };  error: narrowing
S2 s23 { }; // OK: default to 0,0,0


I tried the above case with valgrind, even valgrind had not shown any
un-initialized read.

Document also says it is incomplete and incorrect.

Thanks
Sagar










On Sun, Sep 28, 2014 at 4:41 PM, saurabh singh  wrote:

> Here you go
> http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3337.pdf
> The c++ standard itself. Refer to section 8.5.4 page no. 213.
> Looks like even this int a[10] = {2} is not guaranteed to initialize all
> the elements of the array. Sure gcc provides this but then it becomes a
> compiler specific thing. The language doesn't advocates it.
>
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT
> blog:geekinessthecoolway.blogspot.com
>
> On Sun, Sep 28, 2014 at 3:47 PM, sagar sindwani 
> wrote:
>
>> Thanks Deepak and Rahul for the reply.
>>
>> Do you guys have any standard document or any standard book which defines
>> this?  I totally agree with these answers but I don't have any formal
>> written text.
>>
>> In my example 1, the object is on stack and this lead to a1[0].z to be
>> un-initialized. But as the specified in example 2, Why every element of arr
>> is initialized, it is also on the stack ? Any source to answer this
>> question ?
>>
>> Thanks
>> Sagar
>>
>>
>>
>> On Sun, Sep 28, 2014 at 2:26 PM, Rahul Vatsa 
>> wrote:
>>
>>>
>>> http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly
>>>
>>> On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg 
>>> wrote:
>>>
 Hi

 In example 1, member z will have a garbage value (i.e. 0 in your case )

 Thanks
 Deepak
 On Sep 28, 2014 11:29 AM, "sagar sindwani" 
 wrote:

> I am working on How compilers handle initialization list. I came
> across a case where I am not sure what should be the compiler behaviour.
>
> *Example 1:-*
>
> #include 
>
> class A
> {
> public:
> int x,y,z;
> };
>
> int main()
> {
> A a1[2] =
> {
> { 1,2 },
> { 3,4 }
> };
>
> std::cout << "a1[0].z is " << a1[0].z << std::endl;
>
> return 0;
> }
>
> In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0
> or garbage value, I am not sure on that.
>
> I tried lot of books and some documents , no where I found what C++
> says for initialization of class objects.
>
> You can find handling of below case in almost every book.
>
> *Example 2:- *
>
> int arr[6] = {0};
>
> In Example 2,  compilers will auto-fill all members with 0. It is
> mentioned in books. But when it comes to User-defined datatypes nothing is
> mentioned.
>
>
> Please share your thoughts on this. If you find any document related
> to this, please share it as well.
>
> Thanks
> Sagar
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to algogeeks+unsubscr...@googlegroups.com.
>
  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to algogeeks+unsubscr...@googlegroups.com.

>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] C++ initialization list

2014-09-28 Thread saurabh singh
Here you go
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3337.pdf
The c++ standard itself. Refer to section 8.5.4 page no. 213.
Looks like even this int a[10] = {2} is not guaranteed to initialize all
the elements of the array. Sure gcc provides this but then it becomes a
compiler specific thing. The language doesn't advocates it.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

On Sun, Sep 28, 2014 at 3:47 PM, sagar sindwani 
wrote:

> Thanks Deepak and Rahul for the reply.
>
> Do you guys have any standard document or any standard book which defines
> this?  I totally agree with these answers but I don't have any formal
> written text.
>
> In my example 1, the object is on stack and this lead to a1[0].z to be
> un-initialized. But as the specified in example 2, Why every element of arr
> is initialized, it is also on the stack ? Any source to answer this
> question ?
>
> Thanks
> Sagar
>
>
>
> On Sun, Sep 28, 2014 at 2:26 PM, Rahul Vatsa 
> wrote:
>
>>
>> http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly
>>
>> On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg 
>> wrote:
>>
>>> Hi
>>>
>>> In example 1, member z will have a garbage value (i.e. 0 in your case )
>>>
>>> Thanks
>>> Deepak
>>> On Sep 28, 2014 11:29 AM, "sagar sindwani" 
>>> wrote:
>>>
 I am working on How compilers handle initialization list. I came across
 a case where I am not sure what should be the compiler behaviour.

 *Example 1:-*

 #include 

 class A
 {
 public:
 int x,y,z;
 };

 int main()
 {
 A a1[2] =
 {
 { 1,2 },
 { 3,4 }
 };

 std::cout << "a1[0].z is " << a1[0].z << std::endl;

 return 0;
 }

 In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0
 or garbage value, I am not sure on that.

 I tried lot of books and some documents , no where I found what C++
 says for initialization of class objects.

 You can find handling of below case in almost every book.

 *Example 2:- *

 int arr[6] = {0};

 In Example 2,  compilers will auto-fill all members with 0. It is
 mentioned in books. But when it comes to User-defined datatypes nothing is
 mentioned.


 Please share your thoughts on this. If you find any document related to
 this, please share it as well.

 Thanks
 Sagar

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to algogeeks+unsubscr...@googlegroups.com.

>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] C++ initialization list

2014-09-28 Thread Deepak Garg
Hi sagar

Actually its the compiler which is doing things for you.
GCC or G++ have some features that allows you to initialize array. For
example in your case 2 when you specify a single element gcc intializes the
whole array with 0. You can do this also:
Int arr [6]={[3]=0, [4]=5} p.s. gcc allows u to do this type of
initialisation.
You can refer gcc doc online for more info.
 On Sep 28, 2014 3:59 PM, "sagar sindwani"  wrote:

> Thanks Deepak and Rahul for the reply.
>
> Do you guys have any standard document or any standard book which defines
> this?  I totally agree with these answers but I don't have any formal
> written text.
>
> In my example 1, the object is on stack and this lead to a1[0].z to be
> un-initialized. But as the specified in example 2, Why every element of arr
> is initialized, it is also on the stack ? Any source to answer this
> question ?
>
> Thanks
> Sagar
>
>
>
> On Sun, Sep 28, 2014 at 2:26 PM, Rahul Vatsa 
> wrote:
>
>>
>> http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly
>>
>> On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg 
>> wrote:
>>
>>> Hi
>>>
>>> In example 1, member z will have a garbage value (i.e. 0 in your case )
>>>
>>> Thanks
>>> Deepak
>>> On Sep 28, 2014 11:29 AM, "sagar sindwani" 
>>> wrote:
>>>
 I am working on How compilers handle initialization list. I came across
 a case where I am not sure what should be the compiler behaviour.

 *Example 1:-*

 #include 

 class A
 {
 public:
 int x,y,z;
 };

 int main()
 {
 A a1[2] =
 {
 { 1,2 },
 { 3,4 }
 };

 std::cout << "a1[0].z is " << a1[0].z << std::endl;

 return 0;
 }

 In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0
 or garbage value, I am not sure on that.

 I tried lot of books and some documents , no where I found what C++
 says for initialization of class objects.

 You can find handling of below case in almost every book.

 *Example 2:- *

 int arr[6] = {0};

 In Example 2,  compilers will auto-fill all members with 0. It is
 mentioned in books. But when it comes to User-defined datatypes nothing is
 mentioned.


 Please share your thoughts on this. If you find any document related to
 this, please share it as well.

 Thanks
 Sagar

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to algogeeks+unsubscr...@googlegroups.com.

>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] C++ initialization list

2014-09-28 Thread sagar sindwani
Thanks Deepak and Rahul for the reply.

Do you guys have any standard document or any standard book which defines
this?  I totally agree with these answers but I don't have any formal
written text.

In my example 1, the object is on stack and this lead to a1[0].z to be
un-initialized. But as the specified in example 2, Why every element of arr
is initialized, it is also on the stack ? Any source to answer this
question ?

Thanks
Sagar



On Sun, Sep 28, 2014 at 2:26 PM, Rahul Vatsa  wrote:

>
> http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly
>
> On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg 
> wrote:
>
>> Hi
>>
>> In example 1, member z will have a garbage value (i.e. 0 in your case )
>>
>> Thanks
>> Deepak
>> On Sep 28, 2014 11:29 AM, "sagar sindwani" 
>> wrote:
>>
>>> I am working on How compilers handle initialization list. I came across
>>> a case where I am not sure what should be the compiler behaviour.
>>>
>>> *Example 1:-*
>>>
>>> #include 
>>>
>>> class A
>>> {
>>> public:
>>> int x,y,z;
>>> };
>>>
>>> int main()
>>> {
>>> A a1[2] =
>>> {
>>> { 1,2 },
>>> { 3,4 }
>>> };
>>>
>>> std::cout << "a1[0].z is " << a1[0].z << std::endl;
>>>
>>> return 0;
>>> }
>>>
>>> In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0
>>> or garbage value, I am not sure on that.
>>>
>>> I tried lot of books and some documents , no where I found what C++ says
>>> for initialization of class objects.
>>>
>>> You can find handling of below case in almost every book.
>>>
>>> *Example 2:- *
>>>
>>> int arr[6] = {0};
>>>
>>> In Example 2,  compilers will auto-fill all members with 0. It is
>>> mentioned in books. But when it comes to User-defined datatypes nothing is
>>> mentioned.
>>>
>>>
>>> Please share your thoughts on this. If you find any document related to
>>> this, please share it as well.
>>>
>>> Thanks
>>> Sagar
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] C++ initialization list

2014-09-28 Thread Rahul Vatsa
http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly

On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg 
wrote:

> Hi
>
> In example 1, member z will have a garbage value (i.e. 0 in your case )
>
> Thanks
> Deepak
> On Sep 28, 2014 11:29 AM, "sagar sindwani" 
> wrote:
>
>> I am working on How compilers handle initialization list. I came across a
>> case where I am not sure what should be the compiler behaviour.
>>
>> *Example 1:-*
>>
>> #include 
>>
>> class A
>> {
>> public:
>> int x,y,z;
>> };
>>
>> int main()
>> {
>> A a1[2] =
>> {
>> { 1,2 },
>> { 3,4 }
>> };
>>
>> std::cout << "a1[0].z is " << a1[0].z << std::endl;
>>
>> return 0;
>> }
>>
>> In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0 or
>> garbage value, I am not sure on that.
>>
>> I tried lot of books and some documents , no where I found what C++ says
>> for initialization of class objects.
>>
>> You can find handling of below case in almost every book.
>>
>> *Example 2:- *
>>
>> int arr[6] = {0};
>>
>> In Example 2,  compilers will auto-fill all members with 0. It is
>> mentioned in books. But when it comes to User-defined datatypes nothing is
>> mentioned.
>>
>>
>> Please share your thoughts on this. If you find any document related to
>> this, please share it as well.
>>
>> Thanks
>> Sagar
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] C++ initialization list

2014-09-27 Thread Deepak Garg
Hi

In example 1, member z will have a garbage value (i.e. 0 in your case )

Thanks
Deepak
On Sep 28, 2014 11:29 AM, "sagar sindwani"  wrote:

> I am working on How compilers handle initialization list. I came across a
> case where I am not sure what should be the compiler behaviour.
>
> *Example 1:-*
>
> #include 
>
> class A
> {
> public:
> int x,y,z;
> };
>
> int main()
> {
> A a1[2] =
> {
> { 1,2 },
> { 3,4 }
> };
>
> std::cout << "a1[0].z is " << a1[0].z << std::endl;
>
> return 0;
> }
>
> In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0 or
> garbage value, I am not sure on that.
>
> I tried lot of books and some documents , no where I found what C++ says
> for initialization of class objects.
>
> You can find handling of below case in almost every book.
>
> *Example 2:- *
>
> int arr[6] = {0};
>
> In Example 2,  compilers will auto-fill all members with 0. It is
> mentioned in books. But when it comes to User-defined datatypes nothing is
> mentioned.
>
>
> Please share your thoughts on this. If you find any document related to
> this, please share it as well.
>
> Thanks
> Sagar
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


[algogeeks] C++ initialization list

2014-09-27 Thread sagar sindwani
I am working on How compilers handle initialization list. I came across a
case where I am not sure what should be the compiler behaviour.

*Example 1:-*

#include 

class A
{
public:
int x,y,z;
};

int main()
{
A a1[2] =
{
{ 1,2 },
{ 3,4 }
};

std::cout << "a1[0].z is " << a1[0].z << std::endl;

return 0;
}

In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0 or
garbage value, I am not sure on that.

I tried lot of books and some documents , no where I found what C++ says
for initialization of class objects.

You can find handling of below case in almost every book.

*Example 2:- *

int arr[6] = {0};

In Example 2,  compilers will auto-fill all members with 0. It is mentioned
in books. But when it comes to User-defined datatypes nothing is mentioned.


Please share your thoughts on this. If you find any document related to
this, please share it as well.

Thanks
Sagar

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] c++ this pointer

2013-06-09 Thread Shiva Kumar
Its undefined behavior. In c++ once you delete the pointer(in you case
this) and trying  to access it may lead to undefined behavior you may or
may not get correct value. Its not possible to come to conclusion as result
is not fixed. Delete of pointer will return memory to pool. if it is not
used for allocation the values will be same.


On Wed, Jun 5, 2013 at 9:35 PM, Nitish Raj  wrote:

> @saini  oops... i answered very fast...Let me think...Destruction of this
> pointer. Delete operator works only for heap allocated data. If you object
> is created using new, then you can apply delete this, otherwise behavior is
> undefined
> delete this will not normally affect the this pointer itself, so it can
> still be used to call the function. This behaviour is undefined though - it
> might work, it might not. In general, delete this is a bad idea in C++.
> The only justification for using it is in some reference counted classes,
> and there are beter approaches to reference counting which do not require
> its use.
>
>
> On Wed, Jun 5, 2013 at 9:21 PM, Nitish Raj  wrote:
>
>> When destroy called it will print garbage then it will print desired one.
>> Coz this pointer is self link but with different address of this pointer.
>> So after deletion of pointer this ...
>>  On 5 Jun 2013 14:37, "shubham saini"  wrote:
>>
>>> #include
>>> using namespace std;
>>>
>>> class Test
>>> {
>>> private:
>>>   int x;
>>>   int y;
>>> public:
>>>   Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
>>>   void setX(int a) { x = a; }
>>>   void setY(int b) { y = b; }
>>>   void destroy()  { delete this;
>>> cout<<"x=">>   }
>>>   void print() { cout << "x = " << x << " y = " << y << endl; }
>>> };
>>>
>>> int main()
>>> {
>>>   Test *obj=new Test();
>>>  (*obj).setX(10);
>>>  (*obj).setY(20);
>>>  (*obj).destroy();
>>>   (*obj).print();
>>>   return 0;
>>> }
>>>
>>> i created object dynamically yet how it is still able to print values of
>>> x & y even after deletion of object through 'this' .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>
>>>
>>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




Re: [algogeeks] c++ this pointer

2013-06-05 Thread Nitish Raj
@saini  oops... i answered very fast...Let me think...Destruction of this
pointer. Delete operator works only for heap allocated data. If you object
is created using new, then you can apply delete this, otherwise behavior is
undefined
delete this will not normally affect the this pointer itself, so it can
still be used to call the function. This behaviour is undefined though - it
might work, it might not. In general, delete this is a bad idea in C++. The
only justification for using it is in some reference counted classes, and
there are beter approaches to reference counting which do not require its
use.

On Wed, Jun 5, 2013 at 9:21 PM, Nitish Raj  wrote:

> When destroy called it will print garbage then it will print desired one.
> Coz this pointer is self link but with different address of this pointer.
> So after deletion of pointer this ...
> On 5 Jun 2013 14:37, "shubham saini"  wrote:
>
>> #include
>> using namespace std;
>>
>> class Test
>> {
>> private:
>>   int x;
>>   int y;
>> public:
>>   Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
>>   void setX(int a) { x = a; }
>>   void setY(int b) { y = b; }
>>   void destroy()  { delete this;
>> cout<<"x=">   }
>>   void print() { cout << "x = " << x << " y = " << y << endl; }
>> };
>>
>> int main()
>> {
>>   Test *obj=new Test();
>>  (*obj).setX(10);
>>  (*obj).setY(20);
>>  (*obj).destroy();
>>   (*obj).print();
>>   return 0;
>> }
>>
>> i created object dynamically yet how it is still able to print values of
>> x & y even after deletion of object through 'this' .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




Re: [algogeeks] c++ this pointer

2013-06-05 Thread Nitish Raj
When destroy called it will print garbage then it will print desired one.
Coz this pointer is self link but with different address of this pointer.
So after deletion of pointer this ...
On 5 Jun 2013 14:37, "shubham saini"  wrote:

> #include
> using namespace std;
>
> class Test
> {
> private:
>   int x;
>   int y;
> public:
>   Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
>   void setX(int a) { x = a; }
>   void setY(int b) { y = b; }
>   void destroy()  { delete this;
> cout<<"x="   }
>   void print() { cout << "x = " << x << " y = " << y << endl; }
> };
>
> int main()
> {
>   Test *obj=new Test();
>  (*obj).setX(10);
>  (*obj).setY(20);
>  (*obj).destroy();
>   (*obj).print();
>   return 0;
> }
>
> i created object dynamically yet how it is still able to print values of x
> & y even after deletion of object through 'this' .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




Re: [algogeeks] c++ this pointer

2013-06-05 Thread Jagannath Prasad Das
I guess they are garbage values.


On Fri, May 31, 2013 at 3:41 PM, shubham saini wrote:

> #include
> using namespace std;
>
> class Test
> {
> private:
>   int x;
>   int y;
> public:
>   Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
>   void setX(int a) { x = a; }
>   void setY(int b) { y = b; }
>   void destroy()  { delete this;
> cout<<"x="   }
>   void print() { cout << "x = " << x << " y = " << y << endl; }
> };
>
> int main()
> {
>   Test *obj=new Test();
>  (*obj).setX(10);
>  (*obj).setY(20);
>  (*obj).destroy();
>   (*obj).print();
>   return 0;
> }
>
> i created object dynamically yet how it is still able to print values of x
> & y even after deletion of object through 'this' .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




[algogeeks] c++ this pointer

2013-06-05 Thread shubham saini
#include
using namespace std;

class Test
{
private:
  int x;
  int y;
public:
  Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
  void setX(int a) { x = a; }
  void setY(int b) { y = b; }
  void destroy()  { delete this;
cout<<"x="

Re: [algogeeks] C o/p adobe

2012-11-16 Thread rahul sharma
ok..thnxi got it.your r ryt n i m ryt too:)..thnx

On Fri, Nov 16, 2012 at 11:54 PM, Neeraj Gangwar wrote:

> Ignore last to last mail. Sorry. Do show expanded content in last mail.
> On 16 Nov 2012 23:49, "Neeraj Gangwar"  wrote:
>
>> Yes, it would be like copying the code in the other file. You have to
>> find a way to do it in Dev-C++.
>> In linux it's simple. Just use *gcc file1.c file2.c *in terminal (as
>> told earlier).
>>
>> If you are still confused, Think it this way
>> If you are compiling only one file in which you have declared variable as
>> intern, where would compiler find its actual definition because you are *not
>> compiling *the second file.
>>
>> *file1.c : file in which variable is defined*
>> *file2.c : file in which variable is declared as extern*
>> *
>> *
>> When you compile both the files together, as compiler sees *extern 
>> *declaration,
>> it will check if you have defined that variable somewhere. It will only
>> check files that are being compiled*. So if you are not compiling *file1.c
>> *it will not check that file. That's why you have to compile both the
>> files together.
>>
>> In simple words, what extern does is that it checks if you have defined
>> that variable somewhere* in the code that is *being compiled. *
>>
>> Try following codes
>> *//start of code*
>> *#include*
>> *main() {*
>>
>> *extern int i;*
>> *printf("i = %d", i);*
>> *return 0;*
>>
>> *}*
>> *//end of code*
>> It will show you an error that variable i has not been defined anywhere
>> in the file.
>> *
>> *
>> *//start of code*
>> *#include*
>> *main() {*
>>
>> *extern int i;*
>> *printf("i = %d", i);*
>> *return 0;*
>>
>> *}*
>> *
>> *
>> *int i = 7;*
>> *// end of code*
>> Try above code, it will run and show you the correct result. Your codes
>> are doing precisely the same thing.
>>
>> *#include "file1.c"* or *#include "file2.c"* was based on the same idea.
>>
>> *scope rules apply.
>>
>> Some lines of *the* book The C Programming Language by Dennis Ritchie:
>> There must be only one definition of an external variable among all the
>> files *that make up the*
>> *source program*; other files may contain extern declarations to access
>> it. (There may also be
>> extern declarations in the file containing the definition.) Array sizes
>> must be specified with
>> the definition, but are optional with an extern declaration.
>>
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>> On Fri, Nov 16, 2012 at 10:52 PM, rahul sharma 
>> wrote:
>>
>>> but with adding it willl copy aalll the codewe we dont need to
>>> copy..if we declare int i in file 1...and include in file 2..then i can use
>>> it in file 2 with its extern declaration...m i ryt?
>>>
>>>
>>> On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar 
>>> wrote:
>>>
 For Dev-C++, you have to include one file in another.
 So either add *#include "file1.c" *in file2.c and compile file2.c or
 add *#include "file2.c" *in file1.c and compile file1.c.

 Hope this helps.


 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey 
 wrote:

> @rahulsharma
>  file1.c
>
> #include
> extern int i;// defintion provided in this file itself
> extern int j; // definition provided in file2
> void next()
> {
> ++i;
> other();
> }
> int main()
> {
> ++i;
> printf("%d\n",j);
> printf("%d\n",i);
>next();
> }
> int i=3;
>
> // end of file1.c
>
> file2.c
> extern int i; // declaration of i as extern
> int j=10; // j defined in file2 here which was declared as extern in
> file 1
>
> void other()
> {
> ++i;
> printf("%d\n",i);
> }
> // end of file2.c
>
> compile both file together
> as
> rahul@rahul:~gcc file1.c file2.c
> rahul@rahul:~./a.out
> you will get the required output
>
>
>
>
>
> On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar <
> y.neeraj2...@gmail.com> wrote:
>
>> That's why you are getting the error. You have to compile both the
>> files together. Search on google. I don't use dev c++.
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>> On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma <
>> rahul23111...@gmail.com> wrote:
>>
>>>  No...individually...dev cpp..how to compile both together???
>>>
>>>
>>> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar <
>>> y.neeraj2...@gmail.com> wrote:
>>>
 Which compiler are you using ? Are you compiling both the files

Re: [algogeeks] C o/p adobe

2012-11-16 Thread Neeraj Gangwar
Ignore last to last mail. Sorry. Do show expanded content in last mail.
On 16 Nov 2012 23:49, "Neeraj Gangwar"  wrote:

> Yes, it would be like copying the code in the other file. You have to find
> a way to do it in Dev-C++.
> In linux it's simple. Just use *gcc file1.c file2.c *in terminal (as told
> earlier).
>
> If you are still confused, Think it this way
> If you are compiling only one file in which you have declared variable as
> intern, where would compiler find its actual definition because you are *not
> compiling *the second file.
>
> *file1.c : file in which variable is defined*
> *file2.c : file in which variable is declared as extern*
> *
> *
> When you compile both the files together, as compiler sees *extern 
> *declaration,
> it will check if you have defined that variable somewhere. It will only
> check files that are being compiled*. So if you are not compiling *file1.c
> *it will not check that file. That's why you have to compile both the
> files together.
>
> In simple words, what extern does is that it checks if you have defined
> that variable somewhere* in the code that is *being compiled. *
>
> Try following codes
> *//start of code*
> *#include*
> *main() {*
>
> *extern int i;*
> *printf("i = %d", i);*
> *return 0;*
>
> *}*
> *//end of code*
> It will show you an error that variable i has not been defined anywhere in
> the file.
> *
> *
> *//start of code*
> *#include*
> *main() {*
>
> *extern int i;*
> *printf("i = %d", i);*
> *return 0;*
>
> *}*
> *
> *
> *int i = 7;*
> *// end of code*
> Try above code, it will run and show you the correct result. Your codes
> are doing precisely the same thing.
>
> *#include "file1.c"* or *#include "file2.c"* was based on the same idea.
>
> *scope rules apply.
>
> Some lines of *the* book The C Programming Language by Dennis Ritchie:
> There must be only one definition of an external variable among all the
> files *that make up the*
> *source program*; other files may contain extern declarations to access
> it. (There may also be
> extern declarations in the file containing the definition.) Array sizes
> must be specified with
> the definition, but are optional with an extern declaration.
>
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
> On Fri, Nov 16, 2012 at 10:52 PM, rahul sharma wrote:
>
>> but with adding it willl copy aalll the codewe we dont need to
>> copy..if we declare int i in file 1...and include in file 2..then i can use
>> it in file 2 with its extern declaration...m i ryt?
>>
>>
>> On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar 
>> wrote:
>>
>>> For Dev-C++, you have to include one file in another.
>>> So either add *#include "file1.c" *in file2.c and compile file2.c or
>>> add *#include "file2.c" *in file1.c and compile file1.c.
>>>
>>> Hope this helps.
>>>
>>>
>>> *Neeraj Gangwar*
>>> B.Tech. IV Year
>>> Electronics and Communication IDD
>>> Indian Institute of Technology Roorkee
>>> Contact No. : +91 9897073730
>>>
>>>
>>> On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey wrote:
>>>
 @rahulsharma
  file1.c

 #include
 extern int i;// defintion provided in this file itself
 extern int j; // definition provided in file2
 void next()
 {
 ++i;
 other();
 }
 int main()
 {
 ++i;
 printf("%d\n",j);
 printf("%d\n",i);
next();
 }
 int i=3;

 // end of file1.c

 file2.c
 extern int i; // declaration of i as extern
 int j=10; // j defined in file2 here which was declared as extern in
 file 1

 void other()
 {
 ++i;
 printf("%d\n",i);
 }
 // end of file2.c

 compile both file together
 as
 rahul@rahul:~gcc file1.c file2.c
 rahul@rahul:~./a.out
 you will get the required output





 On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar >>> > wrote:

> That's why you are getting the error. You have to compile both the
> files together. Search on google. I don't use dev c++.
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
> On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma <
> rahul23111...@gmail.com> wrote:
>
>>  No...individually...dev cpp..how to compile both together???
>>
>>
>> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar <
>> y.neeraj2...@gmail.com> wrote:
>>
>>> Which compiler are you using ? Are you compiling both the files
>>> together ?
>>>
>>> *Neeraj Gangwar*
>>> B.Tech. IV Year
>>> Electronics and Communication IDD
>>> Indian Institute of Technology Roorkee
>>> Contact No. : +91 9897073730
>>>
>>>
>>>
>>> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma <
>>> rahul23111...@gmail.com> wrote:
>>>
>>>

Re: [algogeeks] C o/p adobe

2012-11-16 Thread Neeraj Gangwar
Ignore last to last mail. Sorry. Expand previous mail.

*Neeraj Gangwar*
B.Tech. IV Year
Electronics and Communication IDD
Indian Institute of Technology Roorkee
Contact No. : +91 9897073730


On Fri, Nov 16, 2012 at 11:49 PM, Neeraj Gangwar wrote:

> Yes, it would be like copying the code in the other file. You have to find
> a way to do it in Dev-C++.
> In linux it's simple. Just use *gcc file1.c file2.c *in terminal (as told
> earlier).
>
> If you are still confused, Think it this way
> If you are compiling only one file in which you have declared variable as
> intern, where would compiler find its actual definition because you are *not
> compiling *the second file.
>
> *file1.c : file in which variable is defined*
> *file2.c : file in which variable is declared as extern*
> *
> *
> When you compile both the files together, as compiler sees *extern 
> *declaration,
> it will check if you have defined that variable somewhere. It will only
> check files that are being compiled*. So if you are not compiling *file1.c
> *it will not check that file. That's why you have to compile both the
> files together.
>
> In simple words, what extern does is that it checks if you have defined
> that variable somewhere* in the code that is *being compiled. *
>
> Try following codes
> *//start of code*
> *#include*
> *main() {*
>
> *extern int i;*
> *printf("i = %d", i);*
> *return 0;*
>
> *}*
> *//end of code*
> It will show you an error that variable i has not been defined anywhere in
> the file.
> *
> *
> *//start of code*
> *#include*
> *main() {*
>
> *extern int i;*
> *printf("i = %d", i);*
> *return 0;*
>
> *}*
> *
> *
> *int i = 7;*
> *// end of code*
> Try above code, it will run and show you the correct result. Your codes
> are doing precisely the same thing.
>
> *#include "file1.c"* or *#include "file2.c"* was based on the same idea.
>
> *scope rules apply.
>
> Some lines of *the* book The C Programming Language by Dennis Ritchie:
> There must be only one definition of an external variable among all the
> files *that make up the*
> *source program*; other files may contain extern declarations to access
> it. (There may also be
> extern declarations in the file containing the definition.) Array sizes
> must be specified with
> the definition, but are optional with an extern declaration.
>
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
> On Fri, Nov 16, 2012 at 10:52 PM, rahul sharma wrote:
>
>> but with adding it willl copy aalll the codewe we dont need to
>> copy..if we declare int i in file 1...and include in file 2..then i can use
>> it in file 2 with its extern declaration...m i ryt?
>>
>>
>> On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar 
>> wrote:
>>
>>> For Dev-C++, you have to include one file in another.
>>> So either add *#include "file1.c" *in file2.c and compile file2.c or
>>> add *#include "file2.c" *in file1.c and compile file1.c.
>>>
>>> Hope this helps.
>>>
>>>
>>> *Neeraj Gangwar*
>>> B.Tech. IV Year
>>> Electronics and Communication IDD
>>> Indian Institute of Technology Roorkee
>>> Contact No. : +91 9897073730
>>>
>>>
>>> On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey wrote:
>>>
 @rahulsharma
  file1.c

 #include
 extern int i;// defintion provided in this file itself
 extern int j; // definition provided in file2
 void next()
 {
 ++i;
 other();
 }
 int main()
 {
 ++i;
 printf("%d\n",j);
 printf("%d\n",i);
next();
 }
 int i=3;

 // end of file1.c

 file2.c
 extern int i; // declaration of i as extern
 int j=10; // j defined in file2 here which was declared as extern in
 file 1

 void other()
 {
 ++i;
 printf("%d\n",i);
 }
 // end of file2.c

 compile both file together
 as
 rahul@rahul:~gcc file1.c file2.c
 rahul@rahul:~./a.out
 you will get the required output





 On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar >>> > wrote:

> That's why you are getting the error. You have to compile both the
> files together. Search on google. I don't use dev c++.
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
> On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma <
> rahul23111...@gmail.com> wrote:
>
>>  No...individually...dev cpp..how to compile both together???
>>
>>
>> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar <
>> y.neeraj2...@gmail.com> wrote:
>>
>>> Which compiler are you using ? Are you compiling both the files
>>> together ?
>>>
>>> *Neeraj Gangwar*
>>> B.Tech. IV Year
>>> Electronics and Communication IDD
>>> Indian Institute of Technology Roorkee
>>> Contact No. : +91 9897073730
>

Re: [algogeeks] C o/p adobe

2012-11-16 Thread Neeraj Gangwar
Yes, it would be like copying the code in the other file. You have to find
a way to do it in Dev-C++.
In linux it's simple. Just use *gcc file1.c file2.c *in terminal (as told
earlier).

If you are still confused, Think it this way
If you are compiling only one file in which you have declared variable as
intern, where would compiler find its actual definition because you are *not
compiling *the second file.

*file1.c : file in which variable is defined*
*file2.c : file in which variable is declared as extern*
*
*
When you compile both the files together, as compiler sees *extern
*declaration,
it will check if you have defined that variable somewhere. It will only
check files that are being compiled*. So if you are not compiling *file1.c *it
will not check that file. That's why you have to compile both the files
together.

In simple words, what extern does is that it checks if you have defined
that variable somewhere* in the code that is *being compiled. *

Try following codes
*//start of code*
*#include*
*main() {*

*extern int i;*
*printf("i = %d", i);*
*return 0;*

*}*
*//end of code*
It will show you an error that variable i has not been defined anywhere in
the file.
*
*
*//start of code*
*#include*
*main() {*

*extern int i;*
*printf("i = %d", i);*
*return 0;*

*}*
*
*
*int i = 7;*
*// end of code*
Try above code, it will run and show you the correct result. Your codes are
doing precisely the same thing.

*#include "file1.c"* or *#include "file2.c"* was based on the same idea.

*scope rules apply.

Some lines of *the* book The C Programming Language by Dennis Ritchie:
There must be only one definition of an external variable among all the
files *that make up the*
*source program*; other files may contain extern declarations to access it.
(There may also be
extern declarations in the file containing the definition.) Array sizes
must be specified with
the definition, but are optional with an extern declaration.


*Neeraj Gangwar*
B.Tech. IV Year
Electronics and Communication IDD
Indian Institute of Technology Roorkee
Contact No. : +91 9897073730


On Fri, Nov 16, 2012 at 10:52 PM, rahul sharma wrote:

> but with adding it willl copy aalll the codewe we dont need to
> copy..if we declare int i in file 1...and include in file 2..then i can use
> it in file 2 with its extern declaration...m i ryt?
>
>
> On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar wrote:
>
>> For Dev-C++, you have to include one file in another.
>> So either add *#include "file1.c" *in file2.c and compile file2.c or add
>> *#include "file2.c" *in file1.c and compile file1.c.
>>
>> Hope this helps.
>>
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>> On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey wrote:
>>
>>> @rahulsharma
>>>  file1.c
>>>
>>> #include
>>> extern int i;// defintion provided in this file itself
>>> extern int j; // definition provided in file2
>>> void next()
>>> {
>>> ++i;
>>> other();
>>> }
>>> int main()
>>> {
>>> ++i;
>>> printf("%d\n",j);
>>> printf("%d\n",i);
>>>next();
>>> }
>>> int i=3;
>>>
>>> // end of file1.c
>>>
>>> file2.c
>>> extern int i; // declaration of i as extern
>>> int j=10; // j defined in file2 here which was declared as extern in
>>> file 1
>>>
>>> void other()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>> }
>>> // end of file2.c
>>>
>>> compile both file together
>>> as
>>> rahul@rahul:~gcc file1.c file2.c
>>> rahul@rahul:~./a.out
>>> you will get the required output
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar 
>>> wrote:
>>>
 That's why you are getting the error. You have to compile both the
 files together. Search on google. I don't use dev c++.

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma >>> > wrote:

>  No...individually...dev cpp..how to compile both together???
>
>
> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar <
> y.neeraj2...@gmail.com> wrote:
>
>> Which compiler are you using ? Are you compiling both the files
>> together ?
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>>
>> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma <
>> rahul23111...@gmail.com> wrote:
>>
>>> but how can i use extern..if i simply declare a variable in file1 as
>>> int j and try to use in file2 with extern then it shows that j nit
>>> defined..how cum file2 knows in which file j is definedfor e.g if i 
>>> use
>>> extern in file it means that this variable/fxn is defined somewhr 
>>> else.then
>>> what are those files in which it searches this vari

Re: [algogeeks] C o/p adobe

2012-11-16 Thread Neeraj Gangwar
Think it this way

If you are compiling only one file in which you have declared variable as
intern, where would compiler find its actual definition because you are *not
compiling *the second file.

*file1.c : file in which variable is defined*

*file2.c : file in which variable is declared as extern*

When you compile both the files together, as compiler sees *extern
*declaration,
it will check if you have defined that variable somewhere. It will only
check files that are being compiled*. So if you are not compiling *file1.c *it
will not check that file. That's why you have to compile both the files
together.

In simple words, what extern does is that it checks if you have defined
that variable somewhere* in the code that is *being compiled. *

Try following codes

*//start of code*

*#include*

*main() {*

*extern int i;*

*printf("i = %d", i);*

*return 0;*


*}*

*//end of code*

It will show you an error that variable i has not been defined anywhere in
the file.

*//start of code*

*#include*

*main() {*

*extern int i;*

*printf("i = %d", i);*

*return 0;*


*}*

*int i = 7;*

*// end of code*

Try above code, it will run and show you the correct result. Your codes are
doing precisely the same thing.

*#include "file1.c"* or *#include "file2.c"* was based on the same idea.

*scope rules apply.

Some lines of *the* book The C Programming Language by Dennis Ritchie:

There must be only one definition of an external variable among all the
files that make up the

source program; other files may contain extern declarations to access it.
(There may also be

extern declarations in the file containing the definition.) Array sizes
must be specified with

the definition, but are optional with an extern declaration.

*Neeraj Gangwar*
B.Tech. IV Year
Electronics and Communication IDD
Indian Institute of Technology Roorkee
Contact No. : +91 9897073730
On Fri, Nov 16, 2012 at 10:52 PM, rahul sharma wrote:

> but with adding it willl copy aalll the codewe we dont need to
> copy..if we declare int i in file 1...and include in file 2..then i can use
> it in file 2 with its extern declaration...m i ryt?
>
>
> On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar wrote:
>
>> For Dev-C++, you have to include one file in another.
>> So either add *#include "file1.c" *in file2.c and compile file2.c or add
>> *#include "file2.c" *in file1.c and compile file1.c.
>>
>> Hope this helps.
>>
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>> On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey wrote:
>>
>>> @rahulsharma
>>>  file1.c
>>>
>>> #include
>>> extern int i;// defintion provided in this file itself
>>> extern int j; // definition provided in file2
>>> void next()
>>> {
>>> ++i;
>>> other();
>>> }
>>> int main()
>>> {
>>> ++i;
>>> printf("%d\n",j);
>>> printf("%d\n",i);
>>>next();
>>> }
>>> int i=3;
>>>
>>> // end of file1.c
>>>
>>> file2.c
>>> extern int i; // declaration of i as extern
>>> int j=10; // j defined in file2 here which was declared as extern in
>>> file 1
>>>
>>> void other()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>> }
>>> // end of file2.c
>>>
>>> compile both file together
>>> as
>>> rahul@rahul:~gcc file1.c file2.c
>>> rahul@rahul:~./a.out
>>> you will get the required output
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar 
>>> wrote:
>>>
 That's why you are getting the error. You have to compile both the
 files together. Search on google. I don't use dev c++.

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma >>> > wrote:

>  No...individually...dev cpp..how to compile both together???
>
>
> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar <
> y.neeraj2...@gmail.com> wrote:
>
>> Which compiler are you using ? Are you compiling both the files
>> together ?
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>>
>> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma <
>> rahul23111...@gmail.com> wrote:
>>
>>> but how can i use extern..if i simply declare a variable in file1 as
>>> int j and try to use in file2 with extern then it shows that j nit
>>> defined..how cum file2 knows in which file j is definedfor e.g if i 
>>> use
>>> extern in file it means that this variable/fxn is defined somewhr 
>>> else.then
>>> what are those files in which it searches this variable definition..i m
>>> getting errorplese give me 2 files in which one files defines 
>>> variable
>>> and other uses using extern.its not working for me
>>>
>>> On Thu, Nov 1

Re: [algogeeks] C o/p adobe

2012-11-16 Thread rahul sharma
but with adding it willl copy aalll the codewe we dont need to copy..if
we declare int i in file 1...and include in file 2..then i can use it in
file 2 with its extern declaration...m i ryt?

On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar wrote:

> For Dev-C++, you have to include one file in another.
> So either add *#include "file1.c" *in file2.c and compile file2.c or add 
> *#include
> "file2.c" *in file1.c and compile file1.c.
>
> Hope this helps.
>
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
> On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey wrote:
>
>> @rahulsharma
>>  file1.c
>>
>> #include
>> extern int i;// defintion provided in this file itself
>> extern int j; // definition provided in file2
>> void next()
>> {
>> ++i;
>> other();
>> }
>> int main()
>> {
>> ++i;
>> printf("%d\n",j);
>> printf("%d\n",i);
>>next();
>> }
>> int i=3;
>>
>> // end of file1.c
>>
>> file2.c
>> extern int i; // declaration of i as extern
>> int j=10; // j defined in file2 here which was declared as extern in file
>> 1
>>
>> void other()
>> {
>> ++i;
>> printf("%d\n",i);
>> }
>> // end of file2.c
>>
>> compile both file together
>> as
>> rahul@rahul:~gcc file1.c file2.c
>> rahul@rahul:~./a.out
>> you will get the required output
>>
>>
>>
>>
>>
>> On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar 
>> wrote:
>>
>>> That's why you are getting the error. You have to compile both the files
>>> together. Search on google. I don't use dev c++.
>>>
>>> *Neeraj Gangwar*
>>> B.Tech. IV Year
>>> Electronics and Communication IDD
>>> Indian Institute of Technology Roorkee
>>> Contact No. : +91 9897073730
>>>
>>>
>>> On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma 
>>> wrote:
>>>
  No...individually...dev cpp..how to compile both together???


 On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar >>> > wrote:

> Which compiler are you using ? Are you compiling both the files
> together ?
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
>
> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma  > wrote:
>
>> but how can i use extern..if i simply declare a variable in file1 as
>> int j and try to use in file2 with extern then it shows that j nit
>> defined..how cum file2 knows in which file j is definedfor e.g if i 
>> use
>> extern in file it means that this variable/fxn is defined somewhr 
>> else.then
>> what are those files in which it searches this variable definition..i m
>> getting errorplese give me 2 files in which one files defines 
>> variable
>> and other uses using extern.its not working for me
>>
>> On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey <
>> rkd7...@gmail.com> wrote:
>>
>>> @rahul it will compile perfectly well . note that you have declared
>>> j in file 1 as extern and used it and have not provided its definition 
>>> any
>>> where
>>> so getting compile error.
>>> as far as functions are concerned they are external by defaullt as
>>> specified by @shobhit
>>>
>>> i am attaching your corrected code which runs fine ...
>>> file1.c
>>>
>>>
>>> #include
>>> extern int i;
>>> //extern int j; // provide a declaration for this
>>> void next(void);
>>>
>>> int main()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>>
>>> next();
>>> getchar();
>>> }
>>> int i=3;
>>> void next()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>> //printf("%d",j); // since no defintion provided so getting error
>>> other();
>>> }
>>>
>>> file2.c
>>>
>>>
>>> extern int i;
>>> void other()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>> }
>>>
>>> if you want to use j u need to provide defintion either in file 1 or
>>> file 2
>>> output:
>>> 4
>>> 5
>>> 6
>>>
>>>
>>>
>>>
>>> On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma <
>>> rahul23111...@gmail.com> wrote:
>>>
 can nyone provide me dummy code of how exactly to use extern in c..
 in dev environment

 when i declare int i in one fyl
 and try use use with extern int i in another then it doesnt
 compile..plz coment


 On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma <
 rahul23111...@gmail.com> wrote:

> Then why its not running?
>
>
> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
> shobhitgupta1...@gmail.com> wrote:
>
>> http://www.geeksforgeeks.org/archives/840
>>
>> By default, the declaration and definition of a C function have
>> “extern” prepended

Re: [algogeeks] C o/p adobe

2012-11-16 Thread Neeraj Gangwar
For Dev-C++, you have to include one file in another.
So either add *#include "file1.c" *in file2.c and compile file2.c or
add *#include
"file2.c" *in file1.c and compile file1.c.

Hope this helps.


*Neeraj Gangwar*
B.Tech. IV Year
Electronics and Communication IDD
Indian Institute of Technology Roorkee
Contact No. : +91 9897073730


On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey wrote:

> @rahulsharma
>  file1.c
>
> #include
> extern int i;// defintion provided in this file itself
> extern int j; // definition provided in file2
> void next()
> {
> ++i;
> other();
> }
> int main()
> {
> ++i;
> printf("%d\n",j);
> printf("%d\n",i);
>next();
> }
> int i=3;
>
> // end of file1.c
>
> file2.c
> extern int i; // declaration of i as extern
> int j=10; // j defined in file2 here which was declared as extern in file 1
>
> void other()
> {
> ++i;
> printf("%d\n",i);
> }
> // end of file2.c
>
> compile both file together
> as
> rahul@rahul:~gcc file1.c file2.c
> rahul@rahul:~./a.out
> you will get the required output
>
>
>
>
>
> On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar wrote:
>
>> That's why you are getting the error. You have to compile both the files
>> together. Search on google. I don't use dev c++.
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>> On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma 
>> wrote:
>>
>>>  No...individually...dev cpp..how to compile both together???
>>>
>>>
>>> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar 
>>> wrote:
>>>
 Which compiler are you using ? Are you compiling both the files
 together ?

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730



 On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma 
 wrote:

> but how can i use extern..if i simply declare a variable in file1 as
> int j and try to use in file2 with extern then it shows that j nit
> defined..how cum file2 knows in which file j is definedfor e.g if i 
> use
> extern in file it means that this variable/fxn is defined somewhr 
> else.then
> what are those files in which it searches this variable definition..i m
> getting errorplese give me 2 files in which one files defines variable
> and other uses using extern.its not working for me
>
> On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey  > wrote:
>
>> @rahul it will compile perfectly well . note that you have declared j
>> in file 1 as extern and used it and have not provided its definition any
>> where
>> so getting compile error.
>> as far as functions are concerned they are external by defaullt as
>> specified by @shobhit
>>
>> i am attaching your corrected code which runs fine ...
>> file1.c
>>
>>
>> #include
>> extern int i;
>> //extern int j; // provide a declaration for this
>> void next(void);
>>
>> int main()
>> {
>> ++i;
>> printf("%d\n",i);
>>
>> next();
>> getchar();
>> }
>> int i=3;
>> void next()
>> {
>> ++i;
>> printf("%d\n",i);
>> //printf("%d",j); // since no defintion provided so getting error
>> other();
>> }
>>
>> file2.c
>>
>>
>> extern int i;
>> void other()
>> {
>> ++i;
>> printf("%d\n",i);
>> }
>>
>> if you want to use j u need to provide defintion either in file 1 or
>> file 2
>> output:
>> 4
>> 5
>> 6
>>
>>
>>
>>
>> On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma <
>> rahul23111...@gmail.com> wrote:
>>
>>> can nyone provide me dummy code of how exactly to use extern in c..
>>> in dev environment
>>>
>>> when i declare int i in one fyl
>>> and try use use with extern int i in another then it doesnt
>>> compile..plz coment
>>>
>>>
>>> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma <
>>> rahul23111...@gmail.com> wrote:
>>>
 Then why its not running?


 On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
 shobhitgupta1...@gmail.com> wrote:

> http://www.geeksforgeeks.org/archives/840
>
> By default, the declaration and definition of a C function have
> “extern” prepended with them. It means even though we don’t use 
> extern with
> the declaration/definition of C functions, it is present there. For
> example, when we write.
>
> int foo(int arg1, char arg2);
>
> There’s an extern present in the beginning which is hidden and the
> compiler treats it as below.
>
>
>
>
> extern int foo(int arg1, char arg2);
>
>
>  On Wed, Oc

Re: [algogeeks] C o/p adobe

2012-11-15 Thread Rahul Kumar Dubey
@rahulsharma
 file1.c

#include
extern int i;// defintion provided in this file itself
extern int j; // definition provided in file2
void next()
{
++i;
other();
}
int main()
{
++i;
printf("%d\n",j);
printf("%d\n",i);
   next();
}
int i=3;

// end of file1.c

file2.c
extern int i; // declaration of i as extern
int j=10; // j defined in file2 here which was declared as extern in file 1
void other()
{
++i;
printf("%d\n",i);
}
// end of file2.c

compile both file together
as
rahul@rahul:~gcc file1.c file2.c
rahul@rahul:~./a.out
you will get the required output





On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar wrote:

> That's why you are getting the error. You have to compile both the files
> together. Search on google. I don't use dev c++.
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
> On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma wrote:
>
>>  No...individually...dev cpp..how to compile both together???
>>
>>
>> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar 
>> wrote:
>>
>>> Which compiler are you using ? Are you compiling both the files together
>>> ?
>>>
>>> *Neeraj Gangwar*
>>> B.Tech. IV Year
>>> Electronics and Communication IDD
>>> Indian Institute of Technology Roorkee
>>> Contact No. : +91 9897073730
>>>
>>>
>>>
>>> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma 
>>> wrote:
>>>
 but how can i use extern..if i simply declare a variable in file1 as
 int j and try to use in file2 with extern then it shows that j nit
 defined..how cum file2 knows in which file j is definedfor e.g if i use
 extern in file it means that this variable/fxn is defined somewhr else.then
 what are those files in which it searches this variable definition..i m
 getting errorplese give me 2 files in which one files defines variable
 and other uses using extern.its not working for me

 On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey 
 wrote:

> @rahul it will compile perfectly well . note that you have declared j
> in file 1 as extern and used it and have not provided its definition any
> where
> so getting compile error.
> as far as functions are concerned they are external by defaullt as
> specified by @shobhit
>
> i am attaching your corrected code which runs fine ...
> file1.c
>
>
> #include
> extern int i;
> //extern int j; // provide a declaration for this
> void next(void);
>
> int main()
> {
> ++i;
> printf("%d\n",i);
>
> next();
> getchar();
> }
> int i=3;
> void next()
> {
> ++i;
> printf("%d\n",i);
> //printf("%d",j); // since no defintion provided so getting error
> other();
> }
>
> file2.c
>
>
> extern int i;
> void other()
> {
> ++i;
> printf("%d\n",i);
> }
>
> if you want to use j u need to provide defintion either in file 1 or
> file 2
> output:
> 4
> 5
> 6
>
>
>
>
> On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma <
> rahul23111...@gmail.com> wrote:
>
>> can nyone provide me dummy code of how exactly to use extern in c..
>> in dev environment
>>
>> when i declare int i in one fyl
>> and try use use with extern int i in another then it doesnt
>> compile..plz coment
>>
>>
>> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma <
>> rahul23111...@gmail.com> wrote:
>>
>>> Then why its not running?
>>>
>>>
>>> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
>>> shobhitgupta1...@gmail.com> wrote:
>>>
 http://www.geeksforgeeks.org/archives/840

 By default, the declaration and definition of a C function have
 “extern” prepended with them. It means even though we don’t use extern 
 with
 the declaration/definition of C functions, it is present there. For
 example, when we write.

 int foo(int arg1, char arg2);

 There’s an extern present in the beginning which is hidden and the
 compiler treats it as below.



 extern int foo(int arg1, char arg2);


  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma <
 rahul23111...@gmail.com> wrote:

>  Pleaase reply with sol as asp
>
> Fille 1:
>  #include
> extern int i;
>
> extern int j;
> void next(void);
> int main()
> {
> ++i;
> printf("%d",i);
> next();
> getchar();
> }
> int i=3;
> void next()
> {
>  ++i;
>  printf("%d",i);
>  printf("%d",j);
> other();
>  }
> File 2:
>  extern int i;
>
> void other()

Re: [algogeeks] C o/p adobe

2012-11-15 Thread Neeraj Gangwar
That's why you are getting the error. You have to compile both the files
together. Search on google. I don't use dev c++.

*Neeraj Gangwar*
B.Tech. IV Year
Electronics and Communication IDD
Indian Institute of Technology Roorkee
Contact No. : +91 9897073730


On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma wrote:

>  No...individually...dev cpp..how to compile both together???
>
>
> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar wrote:
>
>> Which compiler are you using ? Are you compiling both the files together ?
>>
>> *Neeraj Gangwar*
>> B.Tech. IV Year
>> Electronics and Communication IDD
>> Indian Institute of Technology Roorkee
>> Contact No. : +91 9897073730
>>
>>
>>
>> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma wrote:
>>
>>> but how can i use extern..if i simply declare a variable in file1 as int
>>> j and try to use in file2 with extern then it shows that j nit defined..how
>>> cum file2 knows in which file j is definedfor e.g if i use extern in
>>> file it means that this variable/fxn is defined somewhr else.then what are
>>> those files in which it searches this variable definition..i m getting
>>> errorplese give me 2 files in which one files defines variable and
>>> other uses using extern.its not working for me
>>>
>>> On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey 
>>> wrote:
>>>
 @rahul it will compile perfectly well . note that you have declared j
 in file 1 as extern and used it and have not provided its definition any
 where
 so getting compile error.
 as far as functions are concerned they are external by defaullt as
 specified by @shobhit

 i am attaching your corrected code which runs fine ...
 file1.c


 #include
 extern int i;
 //extern int j; // provide a declaration for this
 void next(void);

 int main()
 {
 ++i;
 printf("%d\n",i);

 next();
 getchar();
 }
 int i=3;
 void next()
 {
 ++i;
 printf("%d\n",i);
 //printf("%d",j); // since no defintion provided so getting error
 other();
 }

 file2.c


 extern int i;
 void other()
 {
 ++i;
 printf("%d\n",i);
 }

 if you want to use j u need to provide defintion either in file 1 or
 file 2
 output:
 4
 5
 6




 On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma >>> > wrote:

> can nyone provide me dummy code of how exactly to use extern in c..
> in dev environment
>
> when i declare int i in one fyl
> and try use use with extern int i in another then it doesnt
> compile..plz coment
>
>
> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma  > wrote:
>
>> Then why its not running?
>>
>>
>> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
>> shobhitgupta1...@gmail.com> wrote:
>>
>>> http://www.geeksforgeeks.org/archives/840
>>>
>>> By default, the declaration and definition of a C function have
>>> “extern” prepended with them. It means even though we don’t use extern 
>>> with
>>> the declaration/definition of C functions, it is present there. For
>>> example, when we write.
>>>
>>> int foo(int arg1, char arg2);
>>>
>>> There’s an extern present in the beginning which is hidden and the
>>> compiler treats it as below.
>>>
>>>
>>> extern int foo(int arg1, char arg2);
>>>
>>>
>>>  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma <
>>> rahul23111...@gmail.com> wrote:
>>>
  Pleaase reply with sol as asp

 Fille 1:
  #include
 extern int i;

 extern int j;
 void next(void);
 int main()
 {
 ++i;
 printf("%d",i);
 next();
 getchar();
 }
 int i=3;
 void next()
 {
  ++i;
  printf("%d",i);
  printf("%d",j);
 other();
  }
 File 2:
  extern int i;

 void other()
 {
  ++i;
 printf("%d",i)'
 }

 How cum file 1 knows what is other();as we havnet define with
 extern void other();
 it should be error
 but when i include the statemetn extern void other,then also it
 shows??
 pls provide me o/p of this questiona nd also tell how use use
 variable of one file in other as simply writing extern in a is not 
 accesing
 global a of other file

 --
 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.
 For more options, visit this group at
 http:/

Re: [algogeeks] C o/p adobe

2012-11-15 Thread rahul sharma
 No...individually...dev cpp..how to compile both together???

On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar wrote:

> Which compiler are you using ? Are you compiling both the files together ?
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
>
> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma wrote:
>
>> but how can i use extern..if i simply declare a variable in file1 as int
>> j and try to use in file2 with extern then it shows that j nit defined..how
>> cum file2 knows in which file j is definedfor e.g if i use extern in
>> file it means that this variable/fxn is defined somewhr else.then what are
>> those files in which it searches this variable definition..i m getting
>> errorplese give me 2 files in which one files defines variable and
>> other uses using extern.its not working for me
>>
>> On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey wrote:
>>
>>> @rahul it will compile perfectly well . note that you have declared j in
>>> file 1 as extern and used it and have not provided its definition any where
>>> so getting compile error.
>>> as far as functions are concerned they are external by defaullt as
>>> specified by @shobhit
>>>
>>> i am attaching your corrected code which runs fine ...
>>> file1.c
>>>
>>>
>>> #include
>>> extern int i;
>>> //extern int j; // provide a declaration for this
>>> void next(void);
>>>
>>> int main()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>>
>>> next();
>>> getchar();
>>> }
>>> int i=3;
>>> void next()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>> //printf("%d",j); // since no defintion provided so getting error
>>> other();
>>> }
>>>
>>> file2.c
>>>
>>>
>>> extern int i;
>>> void other()
>>> {
>>> ++i;
>>> printf("%d\n",i);
>>> }
>>>
>>> if you want to use j u need to provide defintion either in file 1 or
>>> file 2
>>> output:
>>> 4
>>> 5
>>> 6
>>>
>>>
>>>
>>>
>>> On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma 
>>> wrote:
>>>
 can nyone provide me dummy code of how exactly to use extern in c..
 in dev environment

 when i declare int i in one fyl
 and try use use with extern int i in another then it doesnt
 compile..plz coment


 On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma 
 wrote:

> Then why its not running?
>
>
> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
> shobhitgupta1...@gmail.com> wrote:
>
>> http://www.geeksforgeeks.org/archives/840
>>
>> By default, the declaration and definition of a C function have
>> “extern” prepended with them. It means even though we don’t use extern 
>> with
>> the declaration/definition of C functions, it is present there. For
>> example, when we write.
>>
>> int foo(int arg1, char arg2);
>>
>> There’s an extern present in the beginning which is hidden and the
>> compiler treats it as below.
>>
>> extern int foo(int arg1, char arg2);
>>
>>
>>  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma <
>> rahul23111...@gmail.com> wrote:
>>
>>>  Pleaase reply with sol as asp
>>>
>>> Fille 1:
>>>  #include
>>> extern int i;
>>>
>>> extern int j;
>>> void next(void);
>>> int main()
>>> {
>>> ++i;
>>> printf("%d",i);
>>> next();
>>> getchar();
>>> }
>>> int i=3;
>>> void next()
>>> {
>>>  ++i;
>>>  printf("%d",i);
>>>  printf("%d",j);
>>> other();
>>>  }
>>> File 2:
>>>  extern int i;
>>>
>>> void other()
>>> {
>>>  ++i;
>>> printf("%d",i)'
>>> }
>>>
>>> How cum file 1 knows what is other();as we havnet define with
>>> extern void other();
>>> it should be error
>>> but when i include the statemetn extern void other,then also it
>>> shows??
>>> pls provide me o/p of this questiona nd also tell how use use
>>> variable of one file in other as simply writing extern in a is not 
>>> accesing
>>> global a of other file
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
  --
 You received this m

Re: [algogeeks] C o/p adobe

2012-11-15 Thread Neeraj Gangwar
Which compiler are you using ? Are you compiling both the files together ?

*Neeraj Gangwar*
B.Tech. IV Year
Electronics and Communication IDD
Indian Institute of Technology Roorkee
Contact No. : +91 9897073730


On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma wrote:

> but how can i use extern..if i simply declare a variable in file1 as int j
> and try to use in file2 with extern then it shows that j nit defined..how
> cum file2 knows in which file j is definedfor e.g if i use extern in
> file it means that this variable/fxn is defined somewhr else.then what are
> those files in which it searches this variable definition..i m getting
> errorplese give me 2 files in which one files defines variable and
> other uses using extern.its not working for me
>
> On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey wrote:
>
>> @rahul it will compile perfectly well . note that you have declared j in
>> file 1 as extern and used it and have not provided its definition any where
>> so getting compile error.
>> as far as functions are concerned they are external by defaullt as
>> specified by @shobhit
>>
>> i am attaching your corrected code which runs fine ...
>> file1.c
>>
>>
>> #include
>> extern int i;
>> //extern int j; // provide a declaration for this
>> void next(void);
>>
>> int main()
>> {
>> ++i;
>> printf("%d\n",i);
>>
>> next();
>> getchar();
>> }
>> int i=3;
>> void next()
>> {
>> ++i;
>> printf("%d\n",i);
>> //printf("%d",j); // since no defintion provided so getting error
>> other();
>> }
>>
>> file2.c
>>
>>
>> extern int i;
>> void other()
>> {
>> ++i;
>> printf("%d\n",i);
>> }
>>
>> if you want to use j u need to provide defintion either in file 1 or file
>> 2
>> output:
>> 4
>> 5
>> 6
>>
>>
>>
>>
>> On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma 
>> wrote:
>>
>>> can nyone provide me dummy code of how exactly to use extern in c..
>>> in dev environment
>>>
>>> when i declare int i in one fyl
>>> and try use use with extern int i in another then it doesnt compile..plz
>>> coment
>>>
>>>
>>> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma 
>>> wrote:
>>>
 Then why its not running?


 On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
 shobhitgupta1...@gmail.com> wrote:

> http://www.geeksforgeeks.org/archives/840
>
> By default, the declaration and definition of a C function have
> “extern” prepended with them. It means even though we don’t use extern 
> with
> the declaration/definition of C functions, it is present there. For
> example, when we write.
>
> int foo(int arg1, char arg2);
>
> There’s an extern present in the beginning which is hidden and the
> compiler treats it as below.
>
>
> extern int foo(int arg1, char arg2);
>
>
>  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma <
> rahul23111...@gmail.com> wrote:
>
>>  Pleaase reply with sol as asp
>>
>> Fille 1:
>>  #include
>> extern int i;
>>
>> extern int j;
>> void next(void);
>> int main()
>> {
>> ++i;
>> printf("%d",i);
>> next();
>> getchar();
>> }
>> int i=3;
>> void next()
>> {
>>  ++i;
>>  printf("%d",i);
>>  printf("%d",j);
>> other();
>>  }
>> File 2:
>>  extern int i;
>>
>> void other()
>> {
>>  ++i;
>> printf("%d",i)'
>> }
>>
>> How cum file 1 knows what is other();as we havnet define with
>> extern void other();
>> it should be error
>> but when i include the statemetn extern void other,then also it
>> shows??
>> pls provide me o/p of this questiona nd also tell how use use
>> variable of one file in other as simply writing extern in a is not 
>> accesing
>> global a of other file
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>


>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http:/

Re: [algogeeks] C o/p adobe

2012-11-15 Thread rahul sharma
but how can i use extern..if i simply declare a variable in file1 as int j
and try to use in file2 with extern then it shows that j nit defined..how
cum file2 knows in which file j is definedfor e.g if i use extern in
file it means that this variable/fxn is defined somewhr else.then what are
those files in which it searches this variable definition..i m getting
errorplese give me 2 files in which one files defines variable and
other uses using extern.its not working for me

On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey wrote:

> @rahul it will compile perfectly well . note that you have declared j in
> file 1 as extern and used it and have not provided its definition any where
> so getting compile error.
> as far as functions are concerned they are external by defaullt as
> specified by @shobhit
>
> i am attaching your corrected code which runs fine ...
> file1.c
>
>
> #include
> extern int i;
> //extern int j; // provide a declaration for this
> void next(void);
>
> int main()
> {
> ++i;
> printf("%d\n",i);
>
> next();
> getchar();
> }
> int i=3;
> void next()
> {
> ++i;
> printf("%d\n",i);
> //printf("%d",j); // since no defintion provided so getting error
> other();
> }
>
> file2.c
>
>
> extern int i;
> void other()
> {
> ++i;
> printf("%d\n",i);
> }
>
> if you want to use j u need to provide defintion either in file 1 or file 2
> output:
> 4
> 5
> 6
>
>
>
>
> On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma wrote:
>
>> can nyone provide me dummy code of how exactly to use extern in c..
>> in dev environment
>>
>> when i declare int i in one fyl
>> and try use use with extern int i in another then it doesnt compile..plz
>> coment
>>
>>
>> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma wrote:
>>
>>> Then why its not running?
>>>
>>>
>>> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
>>> shobhitgupta1...@gmail.com> wrote:
>>>
 http://www.geeksforgeeks.org/archives/840

 By default, the declaration and definition of a C function have
 “extern” prepended with them. It means even though we don’t use extern with
 the declaration/definition of C functions, it is present there. For
 example, when we write.

 int foo(int arg1, char arg2);

 There’s an extern present in the beginning which is hidden and the
 compiler treats it as below.

 extern int foo(int arg1, char arg2);


  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma >>> > wrote:

>  Pleaase reply with sol as asp
>
> Fille 1:
>  #include
> extern int i;
>
> extern int j;
> void next(void);
> int main()
> {
> ++i;
> printf("%d",i);
> next();
> getchar();
> }
> int i=3;
> void next()
> {
>  ++i;
>  printf("%d",i);
>  printf("%d",j);
> other();
>  }
> File 2:
>  extern int i;
>
> void other()
> {
>  ++i;
> printf("%d",i)'
> }
>
> How cum file 1 knows what is other();as we havnet define with
> extern void other();
> it should be error
> but when i include the statemetn extern void other,then also it shows??
> pls provide me o/p of this questiona nd also tell how use use variable
> of one file in other as simply writing extern in a is not accesing global 
> a
> of other file
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

 --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> *RAHUL KUMAR DUBEY*
> *BTech-3rd  year *
> *Computer Science &Engineering *
> *Motilal Nehru National Institute Of Technology*
> *Allahabad[211004],UP.*
>
>  --
> 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.
> For more options, v

Re: [algogeeks] C o/p adobe

2012-11-14 Thread Rahul Kumar Dubey
@rahul it will compile perfectly well . note that you have declared j in
file 1 as extern and used it and have not provided its definition any where
so getting compile error.
as far as functions are concerned they are external by defaullt as
specified by @shobhit

i am attaching your corrected code which runs fine ...
file1.c

#include
extern int i;
//extern int j; // provide a declaration for this
void next(void);

int main()
{
++i;
printf("%d\n",i);
next();
getchar();
}
int i=3;
void next()
{
++i;
printf("%d\n",i);
//printf("%d",j); // since no defintion provided so getting error
other();
}

file2.c

extern int i;
void other()
{
++i;
printf("%d\n",i);
}

if you want to use j u need to provide defintion either in file 1 or file 2
output:
4
5
6




On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma wrote:

> can nyone provide me dummy code of how exactly to use extern in c..
> in dev environment
>
> when i declare int i in one fyl
> and try use use with extern int i in another then it doesnt compile..plz
> coment
>
>
> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma wrote:
>
>> Then why its not running?
>>
>>
>> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
>> shobhitgupta1...@gmail.com> wrote:
>>
>>> http://www.geeksforgeeks.org/archives/840
>>>
>>> By default, the declaration and definition of a C function have “extern”
>>> prepended with them. It means even though we don’t use extern with the
>>> declaration/definition of C functions, it is present there. For example,
>>> when we write.
>>>
>>> int foo(int arg1, char arg2);
>>>
>>> There’s an extern present in the beginning which is hidden and the
>>> compiler treats it as below.
>>>
>>> extern int foo(int arg1, char arg2);
>>>
>>>
>>> On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma 
>>> wrote:
>>>
 Pleaase reply with sol as asp

 Fille 1:
 #include
 extern int i;

 extern int j;
 void next(void);
 int main()
 {
 ++i;
 printf("%d",i);
 next();
 getchar();
 }
 int i=3;
 void next()
 {
  ++i;
  printf("%d",i);
  printf("%d",j);
 other();
  }
 File 2:
 extern int i;

 void other()
 {
  ++i;
 printf("%d",i)'
 }

 How cum file 1 knows what is other();as we havnet define with
 extern void other();
 it should be error
 but when i include the statemetn extern void other,then also it shows??
 pls provide me o/p of this questiona nd also tell how use use variable
 of one file in other as simply writing extern in a is not accesing global a
 of other file

 --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-31 Thread dCoder
Thats because you have swapped pointers and printing variables.

On Mon, Oct 29, 2012 at 11:22 PM, rahul sharma wrote:

> I have taken form book...i am writing exact code
>
> #include
> #define swap(a,b,c) c t;t=a,a=b,b=t;
>
>
> int main()
> {
> float a,x;
> a=20.0;
> x=30.0;
> float *p,*q;
> p=&a,q=&x;
> swap(p,q,float*);
> printf("%f %f",a,x);
> getchar();
> }
>
> o/p=20.000 30.000
>
>
> why not swapped???
> On Mon, Oct 29, 2012 at 11:01 PM, atul anand wrote:
>
>> if you think the your expanded version is incorrect.You are wrong ,
>> because int * will hold pointer but you are not allocating address of
>> x ..instead you are allocating x value as an address of x to *t.This
>> wont work.
>> so to make it work you need to save the address of x and y in temp
>> pointers i.e
>>
>>int *p.*q;
>> p=&x;
>> q=&y;
>> int t;
>> t=*p;
>> *p=*q;
>> *q=t;
>> now you can convert it into macro.
>>
>> On 10/29/12, rahul sharma  wrote:
>> > @atul...mistakenly  i have put w at place of t in my last post...i wana
>> say
>> >
>> >
>> >
>> > On Mon, Oct 29, 2012 at 10:07 AM, dCoder  wrote:
>> >
>> >> Just replace your macro with its definition and you will understand.
>> >>
>> >> its not doing swapping of pointers...plz explain
>> >>
>> >
>> >
>> > @dCode i expanded..but its fine...please tell
>> >
>> >> #include
>> >> #define swap(a,b,c) c t;t=a,a=b,b=t
>> >>
>> >> int main
>> >> int x=10,y=20;
>> >> int *p,*q;
>> >> swap(x,y,int*);
>> >>
>> > int * t;
>> > t=x;
>> > x=y;
>> > y=t;
>> >
>> >
>> > There is int* at the end..there is som problem with my
>> > keyborad...:(.acc to me axpanded version is above..but not
>> swapping
>> > two pointerssplz comment
>> >
>> >
>> >
>> >
>> >> On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
>> >> wrote:
>> >>
>> >>> its now doing swapping of pointers...plz explain
>> >>>
>> >>>
>> >>> On Sun, Oct 28, 2012 at 8:08 PM, atul anand
>> >>> wrote:
>> >>>
>>  it should swap
>> 
>>  On 10/28/12, rahul sharma  wrote:
>>  > Why the following code is not able to swap two macros???although it
>>  > is
>>  > easily swapping 2 variables
>>  >
>>  > #include
>>  > #define swap(a,b,c) c t;t=a,a=b,b=t
>>  >
>>  >
>>  > int main
>>  >
>>  >
>>  > int x=10,y=20;
>>  > int *p,*q;
>>  >
>>  > swap(x,y,int);
>>  >
>>  > --
>>  > 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.
>>  > For more options, visit this group at
>>  > http://groups.google.com/group/algogeeks?hl=en.
>>  >
>>  >
>> 
>>  --
>>  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.
>>  For more options, visit this group at
>>  http://groups.google.com/group/algogeeks?hl=en.
>> 
>> 
>> >>>  --
>> >>> 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.
>> >>> For more options, visit this group at
>> >>> http://groups.google.com/group/algogeeks?hl=en.
>> >>>
>> >>
>> >>  --
>> >> 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.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/algogeeks?hl=en.
>> >>
>> >
>> > --
>> > 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.
>> > For more options, visit this group at
>> > http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send emai

Re: [algogeeks] C Macro

2012-10-30 Thread rahul sharma
Yeah its working...actually it was written in book...and i did nt
compilemistake of author

On Tue, Oct 30, 2012 at 12:17 PM, Vikram Pradhan wrote:

> @rahul : dude it's working fine ...check your printf() statement you
> are swapping the pointers and printing the original float values of a and x
> it should be printf("%f%f",*p,*q);
>
> or if you want to swap float values not the pointers then it should be
> swap(a,x,float);
> printf("%f%f",a,x);
>
>
> On Mon, Oct 29, 2012 at 11:30 PM, atul anand wrote:
>
>> well they should not , if you see it closely  pointer p and q
>> contain contain address of a and x.
>> and swap() macro will swap value these pointers are holding i.e adress
>> of a and xbut will it reflect address of a and x ???...NO
>> so if you print the address p and q ...before and after the swap then
>> you should see that after swap p will be holding address of x and
>> q will be holding address of a..that it
>>
>> On 10/29/12, rahul sharma  wrote:
>> > I have taken form book...i am writing exact code
>> >
>> > #include
>> > #define swap(a,b,c) c t;t=a,a=b,b=t;
>> >
>> >
>> > int main()
>> > {
>> > float a,x;
>> > a=20.0;
>> > x=30.0;
>> > float *p,*q;
>> > p=&a,q=&x;
>> > swap(p,q,float*);
>> > printf("%f %f",a,x);
>> > getchar();
>> > }
>> >
>> > o/p=20.000 30.000
>> >
>> >
>> > why not swapped???
>> > On Mon, Oct 29, 2012 at 11:01 PM, atul anand
>> > wrote:
>> >
>> >> if you think the your expanded version is incorrect.You are wrong ,
>> >> because int * will hold pointer but you are not allocating address of
>> >> x ..instead you are allocating x value as an address of x to *t.This
>> >> wont work.
>> >> so to make it work you need to save the address of x and y in temp
>> >> pointers i.e
>> >>
>> >>int *p.*q;
>> >> p=&x;
>> >> q=&y;
>> >> int t;
>> >> t=*p;
>> >> *p=*q;
>> >> *q=t;
>> >> now you can convert it into macro.
>> >>
>> >> On 10/29/12, rahul sharma  wrote:
>> >> > @atul...mistakenly  i have put w at place of t in my last post...i
>> wana
>> >> say
>> >> >
>> >> >
>> >> >
>> >> > On Mon, Oct 29, 2012 at 10:07 AM, dCoder 
>> wrote:
>> >> >
>> >> >> Just replace your macro with its definition and you will understand.
>> >> >>
>> >> >> its not doing swapping of pointers...plz explain
>> >> >>
>> >> >
>> >> >
>> >> > @dCode i expanded..but its fine...please tell
>> >> >
>> >> >> #include
>> >> >> #define swap(a,b,c) c t;t=a,a=b,b=t
>> >> >>
>> >> >> int main
>> >> >> int x=10,y=20;
>> >> >> int *p,*q;
>> >> >> swap(x,y,int*);
>> >> >>
>> >> > int * t;
>> >> > t=x;
>> >> > x=y;
>> >> > y=t;
>> >> >
>> >> >
>> >> > There is int* at the end..there is som problem with my
>> >> > keyborad...:(.acc to me axpanded version is above..but not
>> >> swapping
>> >> > two pointerssplz comment
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >> On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
>> >> >> wrote:
>> >> >>
>> >> >>> its now doing swapping of pointers...plz explain
>> >> >>>
>> >> >>>
>> >> >>> On Sun, Oct 28, 2012 at 8:08 PM, atul anand
>> >> >>> wrote:
>> >> >>>
>> >>  it should swap
>> >> 
>> >>  On 10/28/12, rahul sharma  wrote:
>> >>  > Why the following code is not able to swap two macros???although
>> >>  > it
>> >>  > is
>> >>  > easily swapping 2 variables
>> >>  >
>> >>  > #include
>> >>  > #define swap(a,b,c) c t;t=a,a=b,b=t
>> >>  >
>> >>  >
>> >>  > int main
>> >>  >
>> >>  >
>> >>  > int x=10,y=20;
>> >>  > int *p,*q;
>> >>  >
>> >>  > swap(x,y,int);
>> >>  >
>> >>  > --
>> >>  > 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.
>> >>  > For more options, visit this group at
>> >>  > http://groups.google.com/group/algogeeks?hl=en.
>> >>  >
>> >>  >
>> >> 
>> >>  --
>> >>  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.
>> >>  For more options, visit this group at
>> >>  http://groups.google.com/group/algogeeks?hl=en.
>> >> 
>> >> 
>> >> >>>  --
>> >> >>> 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.
>> >> >>> For more options, visit this group at
>> >> >>> http://groups.google.com/group/algogeeks?hl=en.
>

Re: [algogeeks] C Macro

2012-10-30 Thread Vikram Pradhan
@rahul : dude it's working fine ...check your printf() statement you
are swapping the pointers and printing the original float values of a and x
it should be printf("%f%f",*p,*q);

or if you want to swap float values not the pointers then it should be
swap(a,x,float);
printf("%f%f",a,x);


On Mon, Oct 29, 2012 at 11:30 PM, atul anand wrote:

> well they should not , if you see it closely  pointer p and q
> contain contain address of a and x.
> and swap() macro will swap value these pointers are holding i.e adress
> of a and xbut will it reflect address of a and x ???...NO
> so if you print the address p and q ...before and after the swap then
> you should see that after swap p will be holding address of x and
> q will be holding address of a..that it
>
> On 10/29/12, rahul sharma  wrote:
> > I have taken form book...i am writing exact code
> >
> > #include
> > #define swap(a,b,c) c t;t=a,a=b,b=t;
> >
> >
> > int main()
> > {
> > float a,x;
> > a=20.0;
> > x=30.0;
> > float *p,*q;
> > p=&a,q=&x;
> > swap(p,q,float*);
> > printf("%f %f",a,x);
> > getchar();
> > }
> >
> > o/p=20.000 30.000
> >
> >
> > why not swapped???
> > On Mon, Oct 29, 2012 at 11:01 PM, atul anand
> > wrote:
> >
> >> if you think the your expanded version is incorrect.You are wrong ,
> >> because int * will hold pointer but you are not allocating address of
> >> x ..instead you are allocating x value as an address of x to *t.This
> >> wont work.
> >> so to make it work you need to save the address of x and y in temp
> >> pointers i.e
> >>
> >>int *p.*q;
> >> p=&x;
> >> q=&y;
> >> int t;
> >> t=*p;
> >> *p=*q;
> >> *q=t;
> >> now you can convert it into macro.
> >>
> >> On 10/29/12, rahul sharma  wrote:
> >> > @atul...mistakenly  i have put w at place of t in my last post...i
> wana
> >> say
> >> >
> >> >
> >> >
> >> > On Mon, Oct 29, 2012 at 10:07 AM, dCoder 
> wrote:
> >> >
> >> >> Just replace your macro with its definition and you will understand.
> >> >>
> >> >> its not doing swapping of pointers...plz explain
> >> >>
> >> >
> >> >
> >> > @dCode i expanded..but its fine...please tell
> >> >
> >> >> #include
> >> >> #define swap(a,b,c) c t;t=a,a=b,b=t
> >> >>
> >> >> int main
> >> >> int x=10,y=20;
> >> >> int *p,*q;
> >> >> swap(x,y,int*);
> >> >>
> >> > int * t;
> >> > t=x;
> >> > x=y;
> >> > y=t;
> >> >
> >> >
> >> > There is int* at the end..there is som problem with my
> >> > keyborad...:(.acc to me axpanded version is above..but not
> >> swapping
> >> > two pointerssplz comment
> >> >
> >> >
> >> >
> >> >
> >> >> On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
> >> >> wrote:
> >> >>
> >> >>> its now doing swapping of pointers...plz explain
> >> >>>
> >> >>>
> >> >>> On Sun, Oct 28, 2012 at 8:08 PM, atul anand
> >> >>> wrote:
> >> >>>
> >>  it should swap
> >> 
> >>  On 10/28/12, rahul sharma  wrote:
> >>  > Why the following code is not able to swap two macros???although
> >>  > it
> >>  > is
> >>  > easily swapping 2 variables
> >>  >
> >>  > #include
> >>  > #define swap(a,b,c) c t;t=a,a=b,b=t
> >>  >
> >>  >
> >>  > int main
> >>  >
> >>  >
> >>  > int x=10,y=20;
> >>  > int *p,*q;
> >>  >
> >>  > swap(x,y,int);
> >>  >
> >>  > --
> >>  > 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.
> >>  > For more options, visit this group at
> >>  > http://groups.google.com/group/algogeeks?hl=en.
> >>  >
> >>  >
> >> 
> >>  --
> >>  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.
> >>  For more options, visit this group at
> >>  http://groups.google.com/group/algogeeks?hl=en.
> >> 
> >> 
> >> >>>  --
> >> >>> 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.
> >> >>> For more options, visit this group at
> >> >>> http://groups.google.com/group/algogeeks?hl=en.
> >> >>>
> >> >>
> >> >>  --
> >> >> 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.
> >> >>

Re: [algogeeks] C Function Pointer(Typedef)

2012-10-30 Thread Saurabh Kumar
because, pFunc is just a typedef.
you'd have to instantiate a variable at least in order to call your
function.
like -
 typedef int (*pFunc) (int);
 pFunc fptr = func; //fptr is now a variable on stack which points to your
function.
 fptr(5); // call that function.

On 30 October 2012 01:41, rahul sharma  wrote:

> #include 
> #include 
>
>
> int func(int);
> int main(int count,char *argv[])
> {
>  typedef int (*pFunc) (int);
> pFunc=func;
> getchar();
> }
>
>
>
>
> Y itz not compiling?
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Function Pointer(Typedef)

2012-10-29 Thread Shafi Ahmad
The purpose of typedef is to assign alternative names to existing type.
In your case statement " typedef int (*pFunc) (int);" just assign a new
name pFunc to pointer to function declaration " int (*pFunc) (int);". This
statement is not define any variable. Please see below working code.

#include 
#include 


int func(int);
int main(int count,char *argv[])
{
 typedef int (*pFunc) (int);
* pFunc pf;
*
* pf = func;*
 getchar();
}

Regards,
Shafi

On Tue, Oct 30, 2012 at 1:41 AM, rahul sharma wrote:

> #include 
> #include 
>
>
> int func(int);
> int main(int count,char *argv[])
> {
>  typedef int (*pFunc) (int);
> pFunc=func;
> getchar();
> }
>
>
>
>
> Y itz not compiling?
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Shafi Ahmad
http://in.linkedin.com/in/shafiahmad/

"The difficult we do immediately, the impossible takes a little longer" -
US Army

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C Function Pointer(Typedef)

2012-10-29 Thread rahul sharma
#include 
#include 


int func(int);
int main(int count,char *argv[])
{
 typedef int (*pFunc) (int);
pFunc=func;
getchar();
}




Y itz not compiling?

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
well they should not , if you see it closely  pointer p and q
contain contain address of a and x.
and swap() macro will swap value these pointers are holding i.e adress
of a and xbut will it reflect address of a and x ???...NO
so if you print the address p and q ...before and after the swap then
you should see that after swap p will be holding address of x and
q will be holding address of a..that it

On 10/29/12, rahul sharma  wrote:
> I have taken form book...i am writing exact code
>
> #include
> #define swap(a,b,c) c t;t=a,a=b,b=t;
>
>
> int main()
> {
> float a,x;
> a=20.0;
> x=30.0;
> float *p,*q;
> p=&a,q=&x;
> swap(p,q,float*);
> printf("%f %f",a,x);
> getchar();
> }
>
> o/p=20.000 30.000
>
>
> why not swapped???
> On Mon, Oct 29, 2012 at 11:01 PM, atul anand
> wrote:
>
>> if you think the your expanded version is incorrect.You are wrong ,
>> because int * will hold pointer but you are not allocating address of
>> x ..instead you are allocating x value as an address of x to *t.This
>> wont work.
>> so to make it work you need to save the address of x and y in temp
>> pointers i.e
>>
>>int *p.*q;
>> p=&x;
>> q=&y;
>> int t;
>> t=*p;
>> *p=*q;
>> *q=t;
>> now you can convert it into macro.
>>
>> On 10/29/12, rahul sharma  wrote:
>> > @atul...mistakenly  i have put w at place of t in my last post...i wana
>> say
>> >
>> >
>> >
>> > On Mon, Oct 29, 2012 at 10:07 AM, dCoder  wrote:
>> >
>> >> Just replace your macro with its definition and you will understand.
>> >>
>> >> its not doing swapping of pointers...plz explain
>> >>
>> >
>> >
>> > @dCode i expanded..but its fine...please tell
>> >
>> >> #include
>> >> #define swap(a,b,c) c t;t=a,a=b,b=t
>> >>
>> >> int main
>> >> int x=10,y=20;
>> >> int *p,*q;
>> >> swap(x,y,int*);
>> >>
>> > int * t;
>> > t=x;
>> > x=y;
>> > y=t;
>> >
>> >
>> > There is int* at the end..there is som problem with my
>> > keyborad...:(.acc to me axpanded version is above..but not
>> swapping
>> > two pointerssplz comment
>> >
>> >
>> >
>> >
>> >> On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
>> >> wrote:
>> >>
>> >>> its now doing swapping of pointers...plz explain
>> >>>
>> >>>
>> >>> On Sun, Oct 28, 2012 at 8:08 PM, atul anand
>> >>> wrote:
>> >>>
>>  it should swap
>> 
>>  On 10/28/12, rahul sharma  wrote:
>>  > Why the following code is not able to swap two macros???although
>>  > it
>>  > is
>>  > easily swapping 2 variables
>>  >
>>  > #include
>>  > #define swap(a,b,c) c t;t=a,a=b,b=t
>>  >
>>  >
>>  > int main
>>  >
>>  >
>>  > int x=10,y=20;
>>  > int *p,*q;
>>  >
>>  > swap(x,y,int);
>>  >
>>  > --
>>  > 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.
>>  > For more options, visit this group at
>>  > http://groups.google.com/group/algogeeks?hl=en.
>>  >
>>  >
>> 
>>  --
>>  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.
>>  For more options, visit this group at
>>  http://groups.google.com/group/algogeeks?hl=en.
>> 
>> 
>> >>>  --
>> >>> 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.
>> >>> For more options, visit this group at
>> >>> http://groups.google.com/group/algogeeks?hl=en.
>> >>>
>> >>
>> >>  --
>> >> 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.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/algogeeks?hl=en.
>> >>
>> >
>> > --
>> > 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.
>> > For more options, visit this group at
>> > http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googleg

Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
I have taken form book...i am writing exact code

#include
#define swap(a,b,c) c t;t=a,a=b,b=t;


int main()
{
float a,x;
a=20.0;
x=30.0;
float *p,*q;
p=&a,q=&x;
swap(p,q,float*);
printf("%f %f",a,x);
getchar();
}

o/p=20.000 30.000


why not swapped???
On Mon, Oct 29, 2012 at 11:01 PM, atul anand wrote:

> if you think the your expanded version is incorrect.You are wrong ,
> because int * will hold pointer but you are not allocating address of
> x ..instead you are allocating x value as an address of x to *t.This
> wont work.
> so to make it work you need to save the address of x and y in temp
> pointers i.e
>
>int *p.*q;
> p=&x;
> q=&y;
> int t;
> t=*p;
> *p=*q;
> *q=t;
> now you can convert it into macro.
>
> On 10/29/12, rahul sharma  wrote:
> > @atul...mistakenly  i have put w at place of t in my last post...i wana
> say
> >
> >
> >
> > On Mon, Oct 29, 2012 at 10:07 AM, dCoder  wrote:
> >
> >> Just replace your macro with its definition and you will understand.
> >>
> >> its not doing swapping of pointers...plz explain
> >>
> >
> >
> > @dCode i expanded..but its fine...please tell
> >
> >> #include
> >> #define swap(a,b,c) c t;t=a,a=b,b=t
> >>
> >> int main
> >> int x=10,y=20;
> >> int *p,*q;
> >> swap(x,y,int*);
> >>
> > int * t;
> > t=x;
> > x=y;
> > y=t;
> >
> >
> > There is int* at the end..there is som problem with my
> > keyborad...:(.acc to me axpanded version is above..but not
> swapping
> > two pointerssplz comment
> >
> >
> >
> >
> >> On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
> >> wrote:
> >>
> >>> its now doing swapping of pointers...plz explain
> >>>
> >>>
> >>> On Sun, Oct 28, 2012 at 8:08 PM, atul anand
> >>> wrote:
> >>>
>  it should swap
> 
>  On 10/28/12, rahul sharma  wrote:
>  > Why the following code is not able to swap two macros???although it
>  > is
>  > easily swapping 2 variables
>  >
>  > #include
>  > #define swap(a,b,c) c t;t=a,a=b,b=t
>  >
>  >
>  > int main
>  >
>  >
>  > int x=10,y=20;
>  > int *p,*q;
>  >
>  > swap(x,y,int);
>  >
>  > --
>  > 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.
>  > For more options, visit this group at
>  > http://groups.google.com/group/algogeeks?hl=en.
>  >
>  >
> 
>  --
>  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.
>  For more options, visit this group at
>  http://groups.google.com/group/algogeeks?hl=en.
> 
> 
> >>>  --
> >>> 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.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>>
> >>
> >>  --
> >> 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.
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >
> > --
> > 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.
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
if you think the your expanded version is incorrect.You are wrong ,
because int * will hold pointer but you are not allocating address of
x ..instead you are allocating x value as an address of x to *t.This
wont work.
so to make it work you need to save the address of x and y in temp pointers i.e

   int *p.*q;
p=&x;
q=&y;
int t;
t=*p;
*p=*q;
*q=t;
now you can convert it into macro.

On 10/29/12, rahul sharma  wrote:
> @atul...mistakenly  i have put w at place of t in my last post...i wana say
>
>
>
> On Mon, Oct 29, 2012 at 10:07 AM, dCoder  wrote:
>
>> Just replace your macro with its definition and you will understand.
>>
>> its not doing swapping of pointers...plz explain
>>
>
>
> @dCode i expanded..but its fine...please tell
>
>> #include
>> #define swap(a,b,c) c t;t=a,a=b,b=t
>>
>> int main
>> int x=10,y=20;
>> int *p,*q;
>> swap(x,y,int*);
>>
> int * t;
> t=x;
> x=y;
> y=t;
>
>
> There is int* at the end..there is som problem with my
> keyborad...:(.acc to me axpanded version is above..but not swapping
> two pointerssplz comment
>
>
>
>
>> On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
>> wrote:
>>
>>> its now doing swapping of pointers...plz explain
>>>
>>>
>>> On Sun, Oct 28, 2012 at 8:08 PM, atul anand
>>> wrote:
>>>
 it should swap

 On 10/28/12, rahul sharma  wrote:
 > Why the following code is not able to swap two macros???although it
 > is
 > easily swapping 2 variables
 >
 > #include
 > #define swap(a,b,c) c t;t=a,a=b,b=t
 >
 >
 > int main
 >
 >
 > int x=10,y=20;
 > int *p,*q;
 >
 > swap(x,y,int);
 >
 > --
 > 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.
 > For more options, visit this group at
 > http://groups.google.com/group/algogeeks?hl=en.
 >
 >

 --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
@atul...mistakenly  i have put w at place of t in my last post...i wana say



On Mon, Oct 29, 2012 at 10:07 AM, dCoder  wrote:

> Just replace your macro with its definition and you will understand.
>
> its not doing swapping of pointers...plz explain
>


@dCode i expanded..but its fine...please tell

> #include
> #define swap(a,b,c) c t;t=a,a=b,b=t
>
> int main
> int x=10,y=20;
> int *p,*q;
> swap(x,y,int*);
>
int * t;
t=x;
x=y;
y=t;


There is int* at the end..there is som problem with my
keyborad...:(.acc to me axpanded version is above..but not swapping
two pointerssplz comment




> On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma wrote:
>
>> its now doing swapping of pointers...plz explain
>>
>>
>> On Sun, Oct 28, 2012 at 8:08 PM, atul anand wrote:
>>
>>> it should swap
>>>
>>> On 10/28/12, rahul sharma  wrote:
>>> > Why the following code is not able to swap two macros???although it is
>>> > easily swapping 2 variables
>>> >
>>> > #include
>>> > #define swap(a,b,c) c t;t=a,a=b,b=t
>>> >
>>> >
>>> > int main
>>> >
>>> >
>>> > int x=10,y=20;
>>> > int *p,*q;
>>> >
>>> > swap(x,y,int);
>>> >
>>> > --
>>> > 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.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> >
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
didnt get you... first it was now working , now its working...!!!
 please write clearly about your doubts.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
it should swap

On 10/28/12, rahul sharma  wrote:
> Why the following code is not able to swap two macros???although it is
> easily swapping 2 variables
>
> #include
> #define swap(a,b,c) c t;t=a,a=b,b=t
>
>
> int main
>
>
> int x=10,y=20;
> int *p,*q;
>
> swap(x,y,int);
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C Macro

2012-10-28 Thread rahul sharma
Why the following code is not able to swap two macros???although it is
easily swapping 2 variables

#include
#define swap(a,b,c) c t;t=a,a=b,b=t


int main


int x=10,y=20;
int *p,*q;

swap(x,y,int);

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p adobe

2012-10-24 Thread rahul sharma
can nyone provide me dummy code of how exactly to use extern in c..
in dev environment

when i declare int i in one fyl
and try use use with extern int i in another then it doesnt compile..plz
coment

On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma wrote:

> Then why its not running?
>
>
> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA  > wrote:
>
>> http://www.geeksforgeeks.org/archives/840
>>
>> By default, the declaration and definition of a C function have “extern”
>> prepended with them. It means even though we don’t use extern with the
>> declaration/definition of C functions, it is present there. For example,
>> when we write.
>>
>> int foo(int arg1, char arg2);
>>
>> There’s an extern present in the beginning which is hidden and the
>> compiler treats it as below.
>>
>> extern int foo(int arg1, char arg2);
>>
>>
>> On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma wrote:
>>
>>> Pleaase reply with sol as asp
>>>
>>> Fille 1:
>>> #include
>>> extern int i;
>>>
>>> extern int j;
>>> void next(void);
>>> int main()
>>> {
>>> ++i;
>>> printf("%d",i);
>>> next();
>>> getchar();
>>> }
>>> int i=3;
>>> void next()
>>> {
>>>  ++i;
>>>  printf("%d",i);
>>>  printf("%d",j);
>>> other();
>>>  }
>>> File 2:
>>> extern int i;
>>>
>>> void other()
>>> {
>>>  ++i;
>>> printf("%d",i)'
>>> }
>>>
>>> How cum file 1 knows what is other();as we havnet define with
>>> extern void other();
>>> it should be error
>>> but when i include the statemetn extern void other,then also it shows??
>>> pls provide me o/p of this questiona nd also tell how use use variable
>>> of one file in other as simply writing extern in a is not accesing global a
>>> of other file
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p adobe

2012-10-24 Thread rahul sharma
Then why its not running?

On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA
wrote:

> http://www.geeksforgeeks.org/archives/840
>
> By default, the declaration and definition of a C function have “extern”
> prepended with them. It means even though we don’t use extern with the
> declaration/definition of C functions, it is present there. For example,
> when we write.
>
> int foo(int arg1, char arg2);
>
> There’s an extern present in the beginning which is hidden and the
> compiler treats it as below.
>
> extern int foo(int arg1, char arg2);
>
>
> On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma wrote:
>
>> Pleaase reply with sol as asp
>>
>> Fille 1:
>> #include
>> extern int i;
>>
>> extern int j;
>> void next(void);
>> int main()
>> {
>> ++i;
>> printf("%d",i);
>> next();
>> getchar();
>> }
>> int i=3;
>> void next()
>> {
>>  ++i;
>>  printf("%d",i);
>>  printf("%d",j);
>> other();
>>  }
>> File 2:
>> extern int i;
>>
>> void other()
>> {
>>  ++i;
>> printf("%d",i)'
>> }
>>
>> How cum file 1 knows what is other();as we havnet define with
>> extern void other();
>> it should be error
>> but when i include the statemetn extern void other,then also it shows??
>> pls provide me o/p of this questiona nd also tell how use use variable of
>> one file in other as simply writing extern in a is not accesing global a of
>> other file
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p adobe

2012-10-24 Thread SHOBHIT GUPTA
http://www.geeksforgeeks.org/archives/840

By default, the declaration and definition of a C function have “extern”
prepended with them. It means even though we don’t use extern with the
declaration/definition of C functions, it is present there. For example,
when we write.

int foo(int arg1, char arg2);

There’s an extern present in the beginning which is hidden and the compiler
treats it as below.

extern int foo(int arg1, char arg2);


On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma wrote:

> Pleaase reply with sol as asp
>
> Fille 1:
> #include
> extern int i;
>
> extern int j;
> void next(void);
> int main()
> {
> ++i;
> printf("%d",i);
> next();
> getchar();
> }
> int i=3;
> void next()
> {
>  ++i;
>  printf("%d",i);
>  printf("%d",j);
> other();
>  }
> File 2:
> extern int i;
>
> void other()
> {
>  ++i;
> printf("%d",i)'
> }
>
> How cum file 1 knows what is other();as we havnet define with
> extern void other();
> it should be error
> but when i include the statemetn extern void other,then also it shows??
> pls provide me o/p of this questiona nd also tell how use use variable of
> one file in other as simply writing extern in a is not accesing global a of
> other file
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C o/p adobe

2012-10-24 Thread rahul sharma
Pleaase reply with sol as asp

Fille 1:
#include
extern int i;

extern int j;
void next(void);
int main()
{
++i;
printf("%d",i);
next();
getchar();
}
int i=3;
void next()
{
 ++i;
 printf("%d",i);
 printf("%d",j);
other();
 }
File 2:
extern int i;

void other()
{
 ++i;
printf("%d",i)'
}

How cum file 1 knows what is other();as we havnet define with
extern void other();
it should be error
but when i include the statemetn extern void other,then also it shows??
pls provide me o/p of this questiona nd also tell how use use variable of
one file in other as simply writing extern in a is not accesing global a of
other file

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c code help!!!!

2012-10-20 Thread Saurabh Kumar
It only means - If address in hexadecimal is less than 2 digits, it will
add extra padding 0's. If it's more than 2 digits it will simply print the
address as is.
i.e. suppose If address is *E* it will print: *0E* (padding an extra zero)
that's all.

On 21 October 2012 00:05, rahul sharma  wrote:

> void show_bytes(byte_pointer start, int len)
> {
>  int i;
>  for (i = 0; i < len; i++)
>printf(" %.2x", start[i]);
>  printf("\n");
> }
>
>
>
> byte_pointr is unsigned char *...typedef unsigned char * byte_pointer
> plz tell me use of %.2x  i knowx is for hexadoes it mean print 8
> bites of address in 4 hexa of 2 bits???i cant get xactly plz explain
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] c code help!!!!

2012-10-20 Thread rahul sharma
void show_bytes(byte_pointer start, int len)
{
 int i;
 for (i = 0; i < len; i++)
   printf(" %.2x", start[i]);
 printf("\n");
}



byte_pointr is unsigned char *...typedef unsigned char * byte_pointer
plz tell me use of %.2x  i knowx is for hexadoes it mean print 8
bites of address in 4 hexa of 2 bits???i cant get xactly plz explain

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-10-17 Thread Vikas Kumar
#include
int main()
{
   char str[]={'a','b','c'};
   char str1[]={"abc"};
  printf("%d",sizeof(str));
printf("%d",sizeof(str1));
getchar();
}

This is giving 3 in case of str and 4 in case of str1 bcz str is "array of
character" and str1 is a "string".
For understanding this point consider a integer array int arr[] =
{1,2,3,4}; then for this sizeof(arr) is 16 means 4*sizeof(int). So in the
same way for str in given program it is giving 3*sizeof(char) i.e. 3.

sizeof(anyString) = lengthOfString +1 ( +1 for '\0')
strlen(anyString)  = simple length
sizeof(anyArray) = numberofElementPresentInArray*sizeof(dataType)


-- 
*Thanks,*
*Vikas Kumar*
*
*

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-15 Thread Shivam Rohilla
output will be 2
because of you subtract 2 addresses it gives (diffrence of
addresses)/sizeof(datatype)
(71-60)/4=2



On 13/10/2012, bharat b  wrote:
> #include
> main()
> {
>  int *i,*j;
>  i=(int*)60;
>  j=(int*)71;
>  printf("%d",j-i);
> }
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-15 Thread Atul Singh
if u dereference these pointers.,, underlying os will not allow this.
But in above 60 is stored in pointer varible. and that pointer variable is
in the range of program memory.



-- 

*ATul Singh** Software Engineer**, Interra Systems*
Mobile : +91-9410826039
www.interrrasystems.com
[image: Facebook]  [image:
Twitter]
 [image: LinkedIn] 

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-15 Thread Sairam Ravu
I think it allocates on each process's stack, so it is not an issue,
as each process has got its own stack.

On 10/15/12, bharat b  wrote:
> how can kernel agrees with this ? if we directly access address 60 .. which
> is not in our control ... any malicious thing can happen right ?
>
> On Sun, Oct 14, 2012 at 5:39 PM, Dave  wrote:
>
>> @Bharat: 0x notation indicates hexadecimal, so 0x11 = 1*16 + 1 = 17.
>>
>> Dave
>>
>> On Sunday, October 14, 2012 12:48:24 AM UTC-5, bharat wrote:
>>
>>> @Ashok : I didn't get this answer ..
>>> i=0x3c --> what is this address .. variables has addresses but not the
>>> values right? we are not storing 60 any where right?
>>> 0x11 = 3 in decimal format not 11 base 10.
>>>
>>> typecasting to (int*) needs an address right?
>>> I mean
>>> int b=10;
>>> int * a=(int*)&b;
>>>
>>>
>>>
>>> On Sat, Oct 13, 2012 at 9:10 PM, Ashok Varma  wrote:
>>>
 This gives a clear explanation:

 #include
 main(){
  int *i,*j;
  i=(int*)60;
  j=(int*)71;


  printf
 ("%p
 %p %d",i,j,j-i);}


 op: 0x3c 0x47 2

 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes)


  On Sat, Oct 13, 2012 at 3:36 PM, bharat b
 wrote:

>  #include
> main()
> {
>  int *i,*j;
>  i=(int*)60;
>  j=(int*)71;
>  printf("%d",j-i);
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algo...@googlegroups.com.
> To unsubscribe from this group, send email to algogeeks+...@**
> googlegroups.com.
>
> For more options, visit this group at http://groups.google.com/**
> group/algogeeks?hl=en
> .
>

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+...@**
 googlegroups.com.

 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en .

>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/b1AQOc8Y9wQJ.
>>
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
With love and regards,
Sairam Ravu
I M.Tech(CS)
Sri Sathya Sai Institute of Higher Learning
"To live life, you must think it, measure it, experiment with it, dance it,
paint it, draw it, and calculate it"

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-15 Thread bharat b
how can kernel agrees with this ? if we directly access address 60 .. which
is not in our control ... any malicious thing can happen right ?

On Sun, Oct 14, 2012 at 5:39 PM, Dave  wrote:

> @Bharat: 0x notation indicates hexadecimal, so 0x11 = 1*16 + 1 = 17.
>
> Dave
>
> On Sunday, October 14, 2012 12:48:24 AM UTC-5, bharat wrote:
>
>> @Ashok : I didn't get this answer ..
>> i=0x3c --> what is this address .. variables has addresses but not the
>> values right? we are not storing 60 any where right?
>> 0x11 = 3 in decimal format not 11 base 10.
>>
>> typecasting to (int*) needs an address right?
>> I mean
>> int b=10;
>> int * a=(int*)&b;
>>
>>
>>
>> On Sat, Oct 13, 2012 at 9:10 PM, Ashok Varma  wrote:
>>
>>> This gives a clear explanation:
>>>
>>> #include
>>> main(){
>>>  int *i,*j;
>>>  i=(int*)60;
>>>  j=(int*)71;
>>>
>>>
>>>  printf 
>>> ("%p 
>>> %p %d",i,j,j-i);}
>>>
>>>
>>> op: 0x3c 0x47 2
>>>
>>> 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes)
>>>
>>>
>>>  On Sat, Oct 13, 2012 at 3:36 PM, bharat b wrote:
>>>
  #include
 main()
 {
  int *i,*j;
  i=(int*)60;
  j=(int*)71;
  printf("%d",j-i);
 }

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+...@**
 googlegroups.com.

 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en .

>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algo...@googlegroups.com.
>>> To unsubscribe from this group, send email to algogeeks+...@**
>>> googlegroups.com.
>>>
>>> For more options, visit this group at http://groups.google.com/**
>>> group/algogeeks?hl=en .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/b1AQOc8Y9wQJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-14 Thread Dave
@Bharat: 0x notation indicates hexadecimal, so 0x11 = 1*16 + 1 = 17.
 
Dave

On Sunday, October 14, 2012 12:48:24 AM UTC-5, bharat wrote:

> @Ashok : I didn't get this answer .. 
> i=0x3c --> what is this address .. variables has addresses but not the 
> values right? we are not storing 60 any where right?
> 0x11 = 3 in decimal format not 11 base 10.
>
> typecasting to (int*) needs an address right? 
> I mean 
> int b=10;
> int * a=(int*)&b;
>
>
>
> On Sat, Oct 13, 2012 at 9:10 PM, Ashok Varma 
> > wrote:
>
>> This gives a clear explanation: 
>>
>> #include
>> main(){
>>  int *i,*j;
>>  i=(int*)60;
>>  j=(int*)71;
>>
>>
>>  printf 
>> ("%p %p 
>> %d",i,j,j-i);}
>>
>>
>> op: 0x3c 0x47 2
>>
>> 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes)
>>
>>
>>  On Sat, Oct 13, 2012 at 3:36 PM, bharat b 
>> 
>> > wrote:
>>
>>>  #include
>>> main()
>>> {
>>>  int *i,*j;
>>>  i=(int*)60;
>>>  j=(int*)71;
>>>  printf("%d",j-i);
>>> }
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algo...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> algogeeks+...@googlegroups.com .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Algorithm Geeks" group.
>> To post to this group, send email to algo...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> algogeeks+...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/b1AQOc8Y9wQJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
(int *)60 => 60 is treated as address and 60 = 0x3c
similarly 71 = 0x47

On Sun, Oct 14, 2012 at 11:18 AM, bharat b wrote:

> @Ashok : I didn't get this answer ..
> i=0x3c --> what is this address .. variables has addresses but not the
> values right? we are not storing 60 any where right?
> 0x11 = 3 in decimal format not 11 base 10.
>
> typecasting to (int*) needs an address right?
> I mean
> int b=10;
> int * a=(int*)&b;
>
>
>
> On Sat, Oct 13, 2012 at 9:10 PM, Ashok Varma  wrote:
>
>> This gives a clear explanation:
>>
>> #include
>> main(){
>>  int *i,*j;
>>  i=(int*)60;
>>  j=(int*)71;
>>
>>
>>  printf 
>> ("%p %p 
>> %d",i,j,j-i);}
>>
>>
>> op: 0x3c 0x47 2
>>
>> 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes)
>>
>>
>> On Sat, Oct 13, 2012 at 3:36 PM, bharat b 
>> wrote:
>>
>>> #include
>>> main()
>>> {
>>>  int *i,*j;
>>>  i=(int*)60;
>>>  j=(int*)71;
>>>  printf("%d",j-i);
>>> }
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-13 Thread bharat b
@Ashok : I didn't get this answer ..
i=0x3c --> what is this address .. variables has addresses but not the
values right? we are not storing 60 any where right?
0x11 = 3 in decimal format not 11 base 10.

typecasting to (int*) needs an address right?
I mean
int b=10;
int * a=(int*)&b;



On Sat, Oct 13, 2012 at 9:10 PM, Ashok Varma  wrote:

> This gives a clear explanation:
>
> #include
> main(){
>  int *i,*j;
>  i=(int*)60;
>  j=(int*)71;
>
>  printf 
> ("%p %p 
> %d",i,j,j-i);}
>
>
> op: 0x3c 0x47 2
>
> 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes)
>
>
> On Sat, Oct 13, 2012 at 3:36 PM, bharat b wrote:
>
>> #include
>> main()
>> {
>>  int *i,*j;
>>  i=(int*)60;
>>  j=(int*)71;
>>  printf("%d",j-i);
>> }
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
This gives a clear explanation:

#include
main(){
 int *i,*j;
 i=(int*)60;
 j=(int*)71;
 printf 
("%p
%p %d",i,j,j-i);}


op: 0x3c 0x47 2

0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes)


On Sat, Oct 13, 2012 at 3:36 PM, bharat b wrote:

> #include
> main()
> {
>  int *i,*j;
>  i=(int*)60;
>  j=(int*)71;
>  printf("%d",j-i);
> }
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C prog o/p

2012-10-13 Thread bharat b
#include
main()
{
 int *i,*j;
 i=(int*)60;
 j=(int*)71;
 printf("%d",j-i);
}

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-10-08 Thread rahul sharma
@sachin..thnx for explanation..got it..plz tell

#include


int main()
{
   char str[]={'a','b','c'};
   char str1[]={"abc"};
  printf("%d",sizeof(str));
printf("%d",sizeof(str1));
getchar();
}



why str has size 3 and str1 has 4...NUll should also come after c of
str???then y 3??

On Mon, Oct 8, 2012 at 5:07 PM, Sachin  wrote:

> @rahul According to C specification, half filled array will be filled with
> value 0. In your example you are setting str[0] as 'g' and str[1] as 'k'.
> So the compiler sets str[29] as 0. So you string str becomes
> {'g', 'k', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}
>
> Confusion is arising from the fact that you have created an array of 10
> elements.
>
> To answer you original question "gk" is inherently {'g', 'k', '\0'} and
> has size 3 while {'g', 'k'} has size 2.
>
> Regards,
> Sachin
>
>
> On Saturday, October 6, 2012 9:34:30 PM UTC+5:30, rahul sharma wrote:
>
>> #include
>>
>>
>> int main()
>> {
>> char str[10]={'g','k'};
>> char str1[10]="gh";
>> int i;
>> for(i=0;str1[i]!=NULL;i++)
>> printf("%c",str[i]);
>> getchar();
>> }
>>
>> NUll is there in character array also...make clear me...
>>
>> On Sat, Oct 6, 2012 at 9:22 PM, rahul sharma  wrote:
>>
>>> int main()
>>> {
>>> char str[10]={'g','k'};
>>> char str1[10]="gh";
>>>
>>>
>>> printf("%s",str);
>>> printf("%s",str1);
>>> getchar();
>>> }
>>> then how does this work???
>>> str printing gk...then NULL is automatically appended in this also...plz
>>> tell
>>>
>>>
>>> On Sat, Oct 6, 2012 at 6:33 PM, Rathish Kannan wrote:
>>>
 For string, C appends '\0' internally. hence sizeof(str) returned the
 value 3.
 str1 is char array with two character. hence sizeof(str1) returned the
 value 2.

 --  RK :)


 On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma wrote:

> char str[]="ab";
> char str1[]={'a','b'};
>
> sizeof(str) ...o/p is 3
> sizeof(str1)o/p is 2..
>
> Why so
> plz explain...
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algo...@googlegroups.com.
> To unsubscribe from this group, send email to algogeeks+...@**
> googlegroups.com.
>
> For more options, visit this group at http://groups.google.com/**
> group/algogeeks?hl=en 
> .
>

  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+...@**
 googlegroups.com.

 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en .

>>>
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/65EsWyTnMlEJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-10-08 Thread Sachin
@rahul According to C specification, half filled array will be filled with 
value 0. In your example you are setting str[0] as 'g' and str[1] as 'k'. 
So the compiler sets str[29] as 0. So you string str becomes
{'g', 'k', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}

Confusion is arising from the fact that you have created an array of 10 
elements.

To answer you original question "gk" is inherently {'g', 'k', '\0'} and has 
size 3 while {'g', 'k'} has size 2.

Regards,
Sachin

On Saturday, October 6, 2012 9:34:30 PM UTC+5:30, rahul sharma wrote:
>
> #include
>
>
> int main()
> {
> char str[10]={'g','k'};
> char str1[10]="gh";
> int i;
> for(i=0;str1[i]!=NULL;i++)
> printf("%c",str[i]);
> getchar();
> }
>
> NUll is there in character array also...make clear me...
>
> On Sat, Oct 6, 2012 at 9:22 PM, rahul sharma 
> > wrote:
>
>> int main()
>> {
>> char str[10]={'g','k'};
>> char str1[10]="gh";
>>
>>
>> printf("%s",str);
>> printf("%s",str1);
>> getchar();
>> }
>> then how does this work???
>> str printing gk...then NULL is automatically appended in this also...plz 
>> tell
>>
>>
>> On Sat, Oct 6, 2012 at 6:33 PM, Rathish Kannan 
>> 
>> > wrote:
>>
>>> For string, C appends '\0' internally. hence sizeof(str) returned the 
>>> value 3.
>>> str1 is char array with two character. hence sizeof(str1) returned the 
>>> value 2.
>>>
>>> --  RK :)
>>>
>>>
>>> On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma 
>>> 
>>> > wrote:
>>>
 char str[]="ab"; 
 char str1[]={'a','b'};

 sizeof(str) ...o/p is 3
 sizeof(str1)o/p is 2..

 Why so
 plz explain...
  
 -- 
 You received this message because you are subscribed to the Google 
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algo...@googlegroups.com
 .
 To unsubscribe from this group, send email to 
 algogeeks+...@googlegroups.com .
 For more options, visit this group at 
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algo...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> algogeeks+...@googlegroups.com .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/65EsWyTnMlEJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] c o/p

2012-10-07 Thread rahul sharma
#include
int main()
{
int i;
char ch;

scanf("%c",&ch);

printf("%d",ch);
 //   getchar();
getchar();
}

when i enter one digit no. it showswhen 2 digit it halts...y so???  we
can store 2 digit number like 65 in 8 bit char???plz tell

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C doubt

2012-10-06 Thread atul anand
ch=i++[s]; // in this value is assigned first and then increment will
take place...bcozz you are using post increment.
here i does not have any other option it has to do post increment
before [] comes...but it will not assign value to 'i' ( i.e
incremented 'i' value)
so compiler will do something like this
ch=*(i + s);
i=i+1;

ch=++i[s]; // in this case compiler will rewrite it to something like this ,
ch=++(*(i+s)); // this will increment the value at i[s], pre-increment
is taking place ...so updated i[s] value will be assigned o ch

if you do somthing like this :-
ch=i[s]++; // here post increment is happening , so compiler will
rewrite it somthing like this

// ch will contain old value but if you print i[s] , it will print
incremented value of i[s];
ch=*(i+s);
i[s]=i[s] + 1;


On 10/6/12, rahul sharma  wrote:
> char ch
> ch=i++[s];
>
> printf("%c",ch);  this will print i[s],then i is incrementrd after
> assigning to ch
>
>
> ch=++i[s];// this will inccrement value at i[s]
>
>
> My question is what is role of priority which is making them behaving
> differentI am not getting  y not first i is incremented then i[s] is
> assigned
> plz tell
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C doubt

2012-10-06 Thread rahul sharma
char ch
ch=i++[s];

printf("%c",ch);  this will print i[s],then i is incrementrd after
assigning to ch


ch=++i[s];// this will inccrement value at i[s]


My question is what is role of priority which is making them behaving
differentI am not getting  y not first i is incremented then i[s] is
assigned
plz tell

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-10-06 Thread rahul sharma
#include


int main()
{
char str[10]={'g','k'};
char str1[10]="gh";
int i;
for(i=0;str1[i]!=NULL;i++)
printf("%c",str[i]);
getchar();
}

NUll is there in character array also...make clear me...

On Sat, Oct 6, 2012 at 9:22 PM, rahul sharma wrote:

> int main()
> {
> char str[10]={'g','k'};
> char str1[10]="gh";
>
>
> printf("%s",str);
> printf("%s",str1);
> getchar();
> }
> then how does this work???
> str printing gk...then NULL is automatically appended in this also...plz
> tell
>
>
> On Sat, Oct 6, 2012 at 6:33 PM, Rathish Kannan wrote:
>
>> For string, C appends '\0' internally. hence sizeof(str) returned the
>> value 3.
>> str1 is char array with two character. hence sizeof(str1) returned the
>> value 2.
>>
>> --  RK :)
>>
>>
>> On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma wrote:
>>
>>> char str[]="ab";
>>> char str1[]={'a','b'};
>>>
>>> sizeof(str) ...o/p is 3
>>> sizeof(str1)o/p is 2..
>>>
>>> Why so
>>> plz explain...
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-10-06 Thread rahul sharma
int main()
{
char str[10]={'g','k'};
char str1[10]="gh";


printf("%s",str);
printf("%s",str1);
getchar();
}
then how does this work???
str printing gk...then NULL is automatically appended in this also...plz
tell


On Sat, Oct 6, 2012 at 6:33 PM, Rathish Kannan wrote:

> For string, C appends '\0' internally. hence sizeof(str) returned the
> value 3.
> str1 is char array with two character. hence sizeof(str1) returned the
> value 2.
>
> --  RK :)
>
>
> On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma wrote:
>
>> char str[]="ab";
>> char str1[]={'a','b'};
>>
>> sizeof(str) ...o/p is 3
>> sizeof(str1)o/p is 2..
>>
>> Why so
>> plz explain...
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-10-06 Thread Jaspreet Singh
because of null char in 1st

On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma wrote:

> char str[]="ab";
> char str1[]={'a','b'};
>
> sizeof(str) ...o/p is 3
> sizeof(str1)o/p is 2..
>
> Why so
> plz explain...--
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-10-06 Thread Rathish Kannan
For string, C appends '\0' internally. hence sizeof(str) returned the value
3.
str1 is char array with two character. hence sizeof(str1) returned the
value 2.

--  RK :)


On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma wrote:

> char str[]="ab";
> char str1[]={'a','b'};
>
> sizeof(str) ...o/p is 3
> sizeof(str1)o/p is 2..
>
> Why so
> plz explain...
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C output

2012-10-06 Thread rahul sharma
char str[]="ab";
char str1[]={'a','b'};

sizeof(str) ...o/p is 3
sizeof(str1)o/p is 2..

Why so
plz explain...

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-10 Thread Kapil Agrawal
++i/i++=> 6/6
++i * i++ = 36.00
http://ideone.com/j4n0Q


On Tue, Jul 10, 2012 at 3:13 PM, rahul sharma wrote:

> yeahu r ryt
>
>
> On Tue, Jul 10, 2012 at 10:01 AM, Firoz Khursheed <
> firozkhursh...@gmail.com> wrote:
>
>> Well, when i compiled the code the output ie i is alway i=2,
>>
>> http://ideone.com/AFljo
>> http://ideone.com/87waz
>>
>> This expression  is ambiguous, and compiler dependent.
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-10 Thread vikas
he is right.

On Tue, Jul 10, 2012 at 3:13 PM, rahul sharma wrote:

> yeahu r ryt
>
>
> On Tue, Jul 10, 2012 at 10:01 AM, Firoz Khursheed <
> firozkhursh...@gmail.com> wrote:
>
>> Well, when i compiled the code the output ie i is alway i=2,
>>
>> http://ideone.com/AFljo
>> http://ideone.com/87waz
>>
>> This expression  is ambiguous, and compiler dependent.
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-10 Thread rahul sharma
yeahu r ryt

On Tue, Jul 10, 2012 at 10:01 AM, Firoz Khursheed
wrote:

> Well, when i compiled the code the output ie i is alway i=2,
>
> http://ideone.com/AFljo
> http://ideone.com/87waz
>
> This expression  is ambiguous, and compiler dependent.
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-09 Thread Firoz Khursheed
Well, when i compiled the code the output ie i is alway i=2,

http://ideone.com/AFljo
http://ideone.com/87waz

This expression  is ambiguous, and compiler dependent.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-09 Thread rahul sharma
i dont think it will work like u said...7/5i think it will go as
6/6=1..explain nyone???

On Mon, Jul 9, 2012 at 6:38 PM, Firoz Khursheed wrote:

> int i=5;
> i=++i/i++;
> print i;
>
>
> i=1
> coz ++ operator in c has preference from right to left, therefor  first
> (i++ is ca;cu;ated) i=5 is used then it's incremented ie i=6 now. Now at
> this point of time ++i is calculated, which makes i=7;
> finally / operator is performed and i=7/5 is calculated, which makes i=1.
>
> Similarly,
>  int b=a++*a--;
> can be calculated using the preference rule.
>
> On Mon, Jul 9, 2012 at 12:16 PM, rahul sharma wrote:
>
>> what about post increment??
>>
>>
>> On Sun, Jul 8, 2012 at 10:37 PM, mitaksh gupta wrote:
>>
>>> the o/p will be 2 not 1 because of the post-increment operator.
>>>
>>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma 
>>> wrote:
>>>
 int i=5;
 i=++i/i++;
 print i;


 i=1

 how?
  --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Firoz Khursheed
> Computer Science & Engineering
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-09 Thread Firoz Khursheed
int i=5;
i=++i/i++;
print i;


i=1
coz ++ operator in c has preference from right to left, therefor  first
(i++ is ca;cu;ated) i=5 is used then it's incremented ie i=6 now. Now at
this point of time ++i is calculated, which makes i=7;
finally / operator is performed and i=7/5 is calculated, which makes i=1.

Similarly,
 int b=a++*a--;
can be calculated using the preference rule.

On Mon, Jul 9, 2012 at 12:16 PM, rahul sharma wrote:

> what about post increment??
>
>
> On Sun, Jul 8, 2012 at 10:37 PM, mitaksh gupta  wrote:
>
>> the o/p will be 2 not 1 because of the post-increment operator.
>>
>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma wrote:
>>
>>> int i=5;
>>> i=++i/i++;
>>> print i;
>>>
>>>
>>> i=1
>>>
>>> how?
>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Firoz Khursheed
Computer Science & Engineering

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread rahul sharma
what about post increment??

On Sun, Jul 8, 2012 at 10:37 PM, mitaksh gupta  wrote:

> the o/p will be 2 not 1 because of the post-increment operator.
>
> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma wrote:
>
>> int i=5;
>> i=++i/i++;
>> print i;
>>
>>
>> i=1
>>
>> how?
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread mitaksh gupta
the o/p will be 2 not 1 because of the post-increment operator.

On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma wrote:

> int i=5;
> i=++i/i++;
> print i;
>
>
> i=1
>
> how?
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread atul anand
it violates sequence pt. rule..so output is compiler dependent , but
as there is Lvalue error it would compile fine.
but in prev case pre  decrement expects Lvalue but has r-value instead
bcoz of the post increment.


On 7/9/12, md shaukat ali  wrote:
> then atul what would be the output of this prob...
> int a=10;
> int b=a++*a--;
> prinf ("%d",b);
> On Sun, Jul 8, 2012 at 11:52 PM, atul anand 
> wrote:
>
>> b=--a--; this will result into compiler error because 1st the post
>> decrement will occur and value will be saved in a temp variable . but
>> you cannot apply pre decrement on temp variable.
>>
>> On 7/8/12, vindhya chhabra  wrote:
>> > int a=10;
>> > int b;
>> > b=--a--;
>> > printf("%d %d",a,b);. l value error in this ques..
>> >
>> > On Sun, Jul 8, 2012 at 11:48 PM, vindhya chhabra
>> > wrote:
>> >
>> >> .i think there will be an error in this -l value required, as post
>> >> increment has more precedence than pre increment
>> >>
>> >>
>> >> On Sun, Jul 8, 2012 at 11:44 PM, ashish jain
>> >> wrote:
>> >>
>> >>> I think it should output:
>> >>> 9 9
>> >>>
>> >>>
>> >>> On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali
>> >>> wrote:
>> >>>
>>  but i am confused in this problem...
>>  int a=10;
>>  int b;
>>  b=--a--;
>>  printf("%d %d",a,b);..what will output?
>> 
>> 
>>  On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali
>>  >  > wrote:
>> 
>> > agree with adarsh
>> >
>> >
>> > On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar
>> > wrote:
>> >
>> >> Sorry, its 6/6 and not 6/5,
>> >>
>> >> regds.
>> >>
>> >> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar
>> >> wrote:
>> >>
>> >>> Firstly, this is ambiguous and expressions with multiple
>> >>> increment/decrement operators will get executed according to the
>> >>> compiler.
>> >>>
>> >>> Even if you consider the normal way, as we(humans) percieve it,
>> >>> it
>> >>> will be evaluated as
>> >>> (++i)/(i++), which is 6/5, which is 1.
>> >>>
>> >>> Simple!
>> >>>
>> >>>
>> >>>
>> >>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma <
>> >>> rahul23111...@gmail.com> wrote:
>> >>>
>>  int i=5;
>>  i=++i/i++;
>>  print i;
>> 
>> 
>>  i=1
>> 
>>  how?
>> 
>>  --
>>  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.
>>  For more options, visit this group at
>>  http://groups.google.com/group/algogeeks?hl=en.
>> 
>> >>>
>> >>>
>> >>  --
>> >> 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.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/algogeeks?hl=en.
>> >>
>> >
>> >
>>   --
>>  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.
>>  For more options, visit this group at
>>  http://groups.google.com/group/algogeeks?hl=en.
>> 
>> >>>
>> >>>  --
>> >>> 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.
>> >>> For more options, visit this group at
>> >>> http://groups.google.com/group/algogeeks?hl=en.
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Vindhya Chhabra
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>> > --
>> > Vindhya Chhabra
>> >
>> > --
>> > 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.
>> > For more options, visit this group at
>> > http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>

Re: [algogeeks] C o/p

2012-07-08 Thread md shaukat ali
then atul what would be the output of this prob...
int a=10;
int b=a++*a--;
prinf ("%d",b);
On Sun, Jul 8, 2012 at 11:52 PM, atul anand  wrote:

> b=--a--; this will result into compiler error because 1st the post
> decrement will occur and value will be saved in a temp variable . but
> you cannot apply pre decrement on temp variable.
>
> On 7/8/12, vindhya chhabra  wrote:
> > int a=10;
> > int b;
> > b=--a--;
> > printf("%d %d",a,b);. l value error in this ques..
> >
> > On Sun, Jul 8, 2012 at 11:48 PM, vindhya chhabra
> > wrote:
> >
> >> .i think there will be an error in this -l value required, as post
> >> increment has more precedence than pre increment
> >>
> >>
> >> On Sun, Jul 8, 2012 at 11:44 PM, ashish jain
> >> wrote:
> >>
> >>> I think it should output:
> >>> 9 9
> >>>
> >>>
> >>> On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali
> >>> wrote:
> >>>
>  but i am confused in this problem...
>  int a=10;
>  int b;
>  b=--a--;
>  printf("%d %d",a,b);..what will output?
> 
> 
>  On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali
>    > wrote:
> 
> > agree with adarsh
> >
> >
> > On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar
> > wrote:
> >
> >> Sorry, its 6/6 and not 6/5,
> >>
> >> regds.
> >>
> >> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar
> >> wrote:
> >>
> >>> Firstly, this is ambiguous and expressions with multiple
> >>> increment/decrement operators will get executed according to the
> >>> compiler.
> >>>
> >>> Even if you consider the normal way, as we(humans) percieve it, it
> >>> will be evaluated as
> >>> (++i)/(i++), which is 6/5, which is 1.
> >>>
> >>> Simple!
> >>>
> >>>
> >>>
> >>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma <
> >>> rahul23111...@gmail.com> wrote:
> >>>
>  int i=5;
>  i=++i/i++;
>  print i;
> 
> 
>  i=1
> 
>  how?
> 
>  --
>  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.
>  For more options, visit this group at
>  http://groups.google.com/group/algogeeks?hl=en.
> 
> >>>
> >>>
> >>  --
> >> 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.
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >
> >
>   --
>  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.
>  For more options, visit this group at
>  http://groups.google.com/group/algogeeks?hl=en.
> 
> >>>
> >>>  --
> >>> 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.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>>
> >>
> >>
> >>
> >> --
> >> Vindhya Chhabra
> >>
> >>
> >>
> >>
> >
> >
> > --
> > Vindhya Chhabra
> >
> > --
> > 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.
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread atul anand
b=--a--; this will result into compiler error because 1st the post
decrement will occur and value will be saved in a temp variable . but
you cannot apply pre decrement on temp variable.

On 7/8/12, vindhya chhabra  wrote:
> int a=10;
> int b;
> b=--a--;
> printf("%d %d",a,b);. l value error in this ques..
>
> On Sun, Jul 8, 2012 at 11:48 PM, vindhya chhabra
> wrote:
>
>> .i think there will be an error in this -l value required, as post
>> increment has more precedence than pre increment
>>
>>
>> On Sun, Jul 8, 2012 at 11:44 PM, ashish jain
>> wrote:
>>
>>> I think it should output:
>>> 9 9
>>>
>>>
>>> On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali
>>> wrote:
>>>
 but i am confused in this problem...
 int a=10;
 int b;
 b=--a--;
 printf("%d %d",a,b);..what will output?


 On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali
 >>> > wrote:

> agree with adarsh
>
>
> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar
> wrote:
>
>> Sorry, its 6/6 and not 6/5,
>>
>> regds.
>>
>> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar
>> wrote:
>>
>>> Firstly, this is ambiguous and expressions with multiple
>>> increment/decrement operators will get executed according to the
>>> compiler.
>>>
>>> Even if you consider the normal way, as we(humans) percieve it, it
>>> will be evaluated as
>>> (++i)/(i++), which is 6/5, which is 1.
>>>
>>> Simple!
>>>
>>>
>>>
>>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma <
>>> rahul23111...@gmail.com> wrote:
>>>
 int i=5;
 i=++i/i++;
 print i;


 i=1

 how?

 --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
  --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Vindhya Chhabra
>>
>>
>>
>>
>
>
> --
> Vindhya Chhabra
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread vindhya chhabra
int a=10;
int b;
b=--a--;
printf("%d %d",a,b);. l value error in this ques..

On Sun, Jul 8, 2012 at 11:48 PM, vindhya chhabra
wrote:

> .i think there will be an error in this -l value required, as post
> increment has more precedence than pre increment
>
>
> On Sun, Jul 8, 2012 at 11:44 PM, ashish jain wrote:
>
>> I think it should output:
>> 9 9
>>
>>
>> On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali 
>> wrote:
>>
>>> but i am confused in this problem...
>>> int a=10;
>>> int b;
>>> b=--a--;
>>> printf("%d %d",a,b);..what will output?
>>>
>>>
>>> On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali >> > wrote:
>>>
 agree with adarsh


 On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar wrote:

> Sorry, its 6/6 and not 6/5,
>
> regds.
>
> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar wrote:
>
>> Firstly, this is ambiguous and expressions with multiple
>> increment/decrement operators will get executed according to the 
>> compiler.
>>
>> Even if you consider the normal way, as we(humans) percieve it, it
>> will be evaluated as
>> (++i)/(i++), which is 6/5, which is 1.
>>
>> Simple!
>>
>>
>>
>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma <
>> rahul23111...@gmail.com> wrote:
>>
>>> int i=5;
>>> i=++i/i++;
>>> print i;
>>>
>>>
>>> i=1
>>>
>>> how?
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>


>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Vindhya Chhabra
>
>
>
>


-- 
Vindhya Chhabra

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread vindhya chhabra
.i think there will be an error in this -l value required, as post
increment has more precedence than pre increment

On Sun, Jul 8, 2012 at 11:44 PM, ashish jain wrote:

> I think it should output:
> 9 9
>
>
> On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali 
> wrote:
>
>> but i am confused in this problem...
>> int a=10;
>> int b;
>> b=--a--;
>> printf("%d %d",a,b);..what will output?
>>
>>
>> On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali 
>> wrote:
>>
>>> agree with adarsh
>>>
>>>
>>> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar wrote:
>>>
 Sorry, its 6/6 and not 6/5,

 regds.

 On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar wrote:

> Firstly, this is ambiguous and expressions with multiple
> increment/decrement operators will get executed according to the compiler.
>
> Even if you consider the normal way, as we(humans) percieve it, it
> will be evaluated as
> (++i)/(i++), which is 6/5, which is 1.
>
> Simple!
>
>
>
> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma  > wrote:
>
>> int i=5;
>> i=++i/i++;
>> print i;
>>
>>
>> i=1
>>
>> how?
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
  --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Vindhya Chhabra

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread ashish jain
I think it should output:
9 9

On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali wrote:

> but i am confused in this problem...
> int a=10;
> int b;
> b=--a--;
> printf("%d %d",a,b);..what will output?
>
>
> On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali 
> wrote:
>
>> agree with adarsh
>>
>>
>> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar  wrote:
>>
>>> Sorry, its 6/6 and not 6/5,
>>>
>>> regds.
>>>
>>> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar wrote:
>>>
 Firstly, this is ambiguous and expressions with multiple
 increment/decrement operators will get executed according to the compiler.

 Even if you consider the normal way, as we(humans) percieve it, it will
 be evaluated as
 (++i)/(i++), which is 6/5, which is 1.

 Simple!



 On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma 
 wrote:

> int i=5;
> i=++i/i++;
> print i;
>
>
> i=1
>
> how?
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>


>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread md shaukat ali
but i am confused in this problem...
int a=10;
int b;
b=--a--;
printf("%d %d",a,b);..what will output?

On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali wrote:

> agree with adarsh
>
>
> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar  wrote:
>
>> Sorry, its 6/6 and not 6/5,
>>
>> regds.
>>
>> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar  wrote:
>>
>>> Firstly, this is ambiguous and expressions with multiple
>>> increment/decrement operators will get executed according to the compiler.
>>>
>>> Even if you consider the normal way, as we(humans) percieve it, it will
>>> be evaluated as
>>> (++i)/(i++), which is 6/5, which is 1.
>>>
>>> Simple!
>>>
>>>
>>>
>>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma 
>>> wrote:
>>>
 int i=5;
 i=++i/i++;
 print i;


 i=1

 how?

 --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread md shaukat ali
agree with adarsh


On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar  wrote:

> Sorry, its 6/6 and not 6/5,
>
> regds.
>
> On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar  wrote:
>
>> Firstly, this is ambiguous and expressions with multiple
>> increment/decrement operators will get executed according to the compiler.
>>
>> Even if you consider the normal way, as we(humans) percieve it, it will
>> be evaluated as
>> (++i)/(i++), which is 6/5, which is 1.
>>
>> Simple!
>>
>>
>>
>> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma wrote:
>>
>>> int i=5;
>>> i=++i/i++;
>>> print i;
>>>
>>>
>>> i=1
>>>
>>> how?
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread adarsh kumar
Sorry, its 6/6 and not 6/5,

regds.

On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar  wrote:

> Firstly, this is ambiguous and expressions with multiple
> increment/decrement operators will get executed according to the compiler.
>
> Even if you consider the normal way, as we(humans) percieve it, it will be
> evaluated as
> (++i)/(i++), which is 6/5, which is 1.
>
> Simple!
>
>
>
> On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma wrote:
>
>> int i=5;
>> i=++i/i++;
>> print i;
>>
>>
>> i=1
>>
>> how?
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p

2012-07-08 Thread adarsh kumar
Firstly, this is ambiguous and expressions with multiple
increment/decrement operators will get executed according to the compiler.

Even if you consider the normal way, as we(humans) percieve it, it will be
evaluated as
(++i)/(i++), which is 6/5, which is 1.

Simple!



On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma wrote:

> int i=5;
> i=++i/i++;
> print i;
>
>
> i=1
>
> how?
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C o/p

2012-07-08 Thread rahul sharma
int i=5;
i=++i/i++;
print i;


i=1

how?

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C output

2012-07-03 Thread atul anand
violation of sequence point ruleoutput depends on compiler to compiler.

On Tue, Jul 3, 2012 at 1:22 PM, rahul sharma wrote:

> #include
> #include
> int main()
> {
> int i;
> i=5;
> i=++i/i++;
> printf("%d",i);
> getch();
> }
>
> Why o/p is 1 and not 2??   what happened for post increment???
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C output

2012-07-03 Thread rahul sharma
#include
#include
int main()
{
int i;
i=5;
i=++i/i++;
printf("%d",i);
getch();
}

Why o/p is 1 and not 2??   what happened for post increment???

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c prog problem

2012-06-14 Thread Pradip Singh
102 102 -90 64

On Thu, Jun 14, 2012 at 10:48 AM, Anika Jain  wrote:

> in this by typecasting address of float a to char * u assign the address
> of a to ptr. but as ptr is a character pointer when *ptr is printed only 1
> byte currently pointed by ptr is pointed. when ptr is incremented it points
> to the next higher higher order byte of "a". by this way all bytes of "a"
> are printed using a character pointer
>
> On Wed, Jun 13, 2012 at 11:47 PM, Rahul verma wrote:
>
>> int main()
>> {
>>  int i;
>>  float a=5.2;
>> char *ptr;
>> ptr=(char *)&a;
>>for(i=0;i<=3;i++)
>>   printf("%d ",*ptr++);
>>   return 0;
>> }
>> give me explanation of this code.
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards
> Anika Jain
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
pardeep kumar

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c prog problem

2012-06-13 Thread Anika Jain
in this by typecasting address of float a to char * u assign the address of
a to ptr. but as ptr is a character pointer when *ptr is printed only 1
byte currently pointed by ptr is pointed. when ptr is incremented it points
to the next higher higher order byte of "a". by this way all bytes of "a"
are printed using a character pointer

On Wed, Jun 13, 2012 at 11:47 PM, Rahul verma  wrote:

> int main()
> {
>  int i;
>  float a=5.2;
> char *ptr;
> ptr=(char *)&a;
>for(i=0;i<=3;i++)
>   printf("%d ",*ptr++);
>   return 0;
> }
> give me explanation of this code.
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards
Anika Jain

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] c prog problem

2012-06-13 Thread Rahul verma
int main()
{
 int i;
 float a=5.2;
char *ptr;
ptr=(char *)&a;
   for(i=0;i<=3;i++)
  printf("%d ",*ptr++);
  return 0;
}
give me explanation of this code.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c++ webservice in linux machine

2012-06-11 Thread Hassan Monfared
use gSOAP

On Tue, Jun 12, 2012 at 5:24 AM, rgap  wrote:

> Hi
>
> i want to write a c++ webservice which should work in linux machine
> with apache being the web server.
>
> Are there any libraries which allow you to write server-side
> applications that handle the HTTP requests with Apache being the
> webserver on Linux?
>
> Thanks.
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] c++ webservice in linux machine

2012-06-11 Thread rgap
Hi

i want to write a c++ webservice which should work in linux machine
with apache being the web server.

Are there any libraries which allow you to write server-side
applications that handle the HTTP requests with Apache being the
webserver on Linux?

Thanks.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C concept on memory layout

2012-02-07 Thread Ravi Ranjan
@all

thanx for the explanation..

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C concept on memory layout

2012-02-07 Thread Atul Singh
I think rahul has given a clear solution i.e why the static variable is not
accessible in main() function because of its scope.
I would like to add one more point in this...that  Static variables may be
initialized in their declarations;

however, the initializers must be constant expressions, and initialization
is done only once at compile time when memory is allocated for the static
variable

-- 
ATul Singh | Final Year  | Computer Science & Engineering | NIT
Jalandhar  | 9530739855
|

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C concept on memory layout

2012-02-07 Thread rahul
i think  guys are confuse between scope of variable and lifetime of
variable.
p scope is add function and lifetime of p is till the program run.
so u can't access variable outside the scope of variable whatever is the
lifetime of variable.

u can look at "peter ven den linden" Deep C secrets.

best regards,

On Tue, Feb 7, 2012 at 10:43 AM, Manni mbd  wrote:

> i didn't got .. !! please explain some more..
>
> On 2/7/12, sumit mahamuni  wrote:
> > Hello,
> >
> > Here you are right about variable p in add function that it retains it's
> > value even though function loses its scope. And for main function error
> you
> > are seeing has nothing to do with how that variable is stored?
> > It is about the scope of that variable C compiler sees the scope of
> static
> > variable p  limited to add function only, so other function can't use it.
> > And remember error is at compile time not run time so it is related to
> > compiler not memory. I hope it explains everything.
> >
> > On Tue, Feb 7, 2012 at 9:43 AM, atul anand 
> wrote:
> >
> >> http://www.geeksforgeeks.org/archives/14268
> >>
> >>
> >> On Tue, Feb 7, 2012 at 1:06 AM, gmagog...@gmail.com
> >> wrote:
> >>
> >>> I think you are right about p being in BSS segment and it does last
> even
> >>> the function finishes, however, you may need a pointer to get the data
> >>> out
> >>> of p. Then you can read the data.
> >>>
> >>> Correct me if i am wrong
> >>>
> >>>
> >>> On Mon, Feb 6, 2012 at 1:04 PM, Ravi Ranjan
> >>> wrote:
> >>>
>  i have a confusion in it
> 
>  #include 
>  #include 
> 
> 
>  void add(int,int);
> 
>  int main(int argc, char *argv[])
>  {
> 
>  add(6,3);
>  printf("%d",p);
> 
>    system("PAUSE");
>    return 0;
>  }
> 
> 
>  void add(int a, int b)
>  {
>    static int p;
>  p = a+ b;
>  }
> 
> 
>  here the memory layout says variable "p" is in BSS segment ... so its
> an
>  independent region from stack frame. when the function looses its
>  scope
>  from function defination(add) then still it should be alive... and can
>  be
>  recognized/used by other function(main) but it gves an error of
>  unknown
>  variable "p".  need the correct logic... if i m wrong...
> 
>  thanx
>  ravi
> 
>  --
>  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.
>  For more options, visit this group at
>  http://groups.google.com/group/algogeeks?hl=en.
> 
> >>>
> >>>  --
> >>> 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.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>>
> >>
> >>  --
> >> 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.
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >
> >
> >
> > --
> > Thanks and Regards,
> > Sumit Mahamuni.
> >
> > -- Slow code that scales better can be faster than fast code that doesn't
> > scale!
> > -- Tough times never lasts, but tough people do.
> > -- I love deadlines. I like the whooshing sound they make as they fly
> by. -
> > D. Adams
> >
> > --
> > 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.
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C concept on memory layout

2012-02-07 Thread Manni mbd
i didn't got .. !! please explain some more..

On 2/7/12, sumit mahamuni  wrote:
> Hello,
>
> Here you are right about variable p in add function that it retains it's
> value even though function loses its scope. And for main function error you
> are seeing has nothing to do with how that variable is stored?
> It is about the scope of that variable C compiler sees the scope of static
> variable p  limited to add function only, so other function can't use it.
> And remember error is at compile time not run time so it is related to
> compiler not memory. I hope it explains everything.
>
> On Tue, Feb 7, 2012 at 9:43 AM, atul anand  wrote:
>
>> http://www.geeksforgeeks.org/archives/14268
>>
>>
>> On Tue, Feb 7, 2012 at 1:06 AM, gmagog...@gmail.com
>> wrote:
>>
>>> I think you are right about p being in BSS segment and it does last even
>>> the function finishes, however, you may need a pointer to get the data
>>> out
>>> of p. Then you can read the data.
>>>
>>> Correct me if i am wrong
>>>
>>>
>>> On Mon, Feb 6, 2012 at 1:04 PM, Ravi Ranjan
>>> wrote:
>>>
 i have a confusion in it

 #include 
 #include 


 void add(int,int);

 int main(int argc, char *argv[])
 {

 add(6,3);
 printf("%d",p);

   system("PAUSE");
   return 0;
 }


 void add(int a, int b)
 {
   static int p;
 p = a+ b;
 }


 here the memory layout says variable "p" is in BSS segment ... so its an
 independent region from stack frame. when the function looses its
 scope
 from function defination(add) then still it should be alive... and can
 be
 recognized/used by other function(main) but it gves an error of
 unknown
 variable "p".  need the correct logic... if i m wrong...

 thanx
 ravi

 --
 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.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Thanks and Regards,
> Sumit Mahamuni.
>
> -- Slow code that scales better can be faster than fast code that doesn't
> scale!
> -- Tough times never lasts, but tough people do.
> -- I love deadlines. I like the whooshing sound they make as they fly by. -
> D. Adams
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C concept on memory layout

2012-02-06 Thread sumit mahamuni
Hello,

Here you are right about variable p in add function that it retains it's
value even though function loses its scope. And for main function error you
are seeing has nothing to do with how that variable is stored?
It is about the scope of that variable C compiler sees the scope of static
variable p  limited to add function only, so other function can't use it.
And remember error is at compile time not run time so it is related to
compiler not memory. I hope it explains everything.

On Tue, Feb 7, 2012 at 9:43 AM, atul anand  wrote:

> http://www.geeksforgeeks.org/archives/14268
>
>
> On Tue, Feb 7, 2012 at 1:06 AM, gmagog...@gmail.com 
> wrote:
>
>> I think you are right about p being in BSS segment and it does last even
>> the function finishes, however, you may need a pointer to get the data out
>> of p. Then you can read the data.
>>
>> Correct me if i am wrong
>>
>>
>> On Mon, Feb 6, 2012 at 1:04 PM, Ravi Ranjan wrote:
>>
>>> i have a confusion in it
>>>
>>> #include 
>>> #include 
>>>
>>>
>>> void add(int,int);
>>>
>>> int main(int argc, char *argv[])
>>> {
>>>
>>> add(6,3);
>>> printf("%d",p);
>>>
>>>   system("PAUSE");
>>>   return 0;
>>> }
>>>
>>>
>>> void add(int a, int b)
>>> {
>>>   static int p;
>>> p = a+ b;
>>> }
>>>
>>>
>>> here the memory layout says variable "p" is in BSS segment ... so its an
>>> independent region from stack frame. when the function looses its scope
>>> from function defination(add) then still it should be alive... and can be
>>> recognized/used by other function(main) but it gves an error of unknown
>>> variable "p".  need the correct logic... if i m wrong...
>>>
>>> thanx
>>> ravi
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C concept on memory layout

2012-02-06 Thread atul anand
http://www.geeksforgeeks.org/archives/14268

On Tue, Feb 7, 2012 at 1:06 AM, gmagog...@gmail.com wrote:

> I think you are right about p being in BSS segment and it does last even
> the function finishes, however, you may need a pointer to get the data out
> of p. Then you can read the data.
>
> Correct me if i am wrong
>
>
> On Mon, Feb 6, 2012 at 1:04 PM, Ravi Ranjan wrote:
>
>> i have a confusion in it
>>
>> #include 
>> #include 
>>
>>
>> void add(int,int);
>>
>> int main(int argc, char *argv[])
>> {
>>
>> add(6,3);
>> printf("%d",p);
>>
>>   system("PAUSE");
>>   return 0;
>> }
>>
>>
>> void add(int a, int b)
>> {
>>   static int p;
>> p = a+ b;
>> }
>>
>>
>> here the memory layout says variable "p" is in BSS segment ... so its an
>> independent region from stack frame. when the function looses its scope
>> from function defination(add) then still it should be alive... and can be
>> recognized/used by other function(main) but it gves an error of unknown
>> variable "p".  need the correct logic... if i m wrong...
>>
>> thanx
>> ravi
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C concept on memory layout

2012-02-06 Thread gmagog...@gmail.com
I think you are right about p being in BSS segment and it does last even
the function finishes, however, you may need a pointer to get the data out
of p. Then you can read the data.

Correct me if i am wrong


On Mon, Feb 6, 2012 at 1:04 PM, Ravi Ranjan  wrote:

> i have a confusion in it
>
> #include 
> #include 
>
>
> void add(int,int);
>
> int main(int argc, char *argv[])
> {
>
> add(6,3);
> printf("%d",p);
>
>   system("PAUSE");
>   return 0;
> }
>
>
> void add(int a, int b)
> {
>   static int p;
> p = a+ b;
> }
>
>
> here the memory layout says variable "p" is in BSS segment ... so its an
> independent region from stack frame. when the function looses its scope
> from function defination(add) then still it should be alive... and can be
> recognized/used by other function(main) but it gves an error of unknown
> variable "p".  need the correct logic... if i m wrong...
>
> thanx
> ravi
>
> --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C concept on memory layout

2012-02-06 Thread Ravi Ranjan
i have a confusion in it

#include 
#include 


void add(int,int);

int main(int argc, char *argv[])
{

add(6,3);
printf("%d",p);

  system("PAUSE");
  return 0;
}


void add(int a, int b)
{
  static int p;
p = a+ b;
}


here the memory layout says variable "p" is in BSS segment ... so its an
independent region from stack frame. when the function looses its scope
from function defination(add) then still it should be alive... and can be
recognized/used by other function(main) but it gves an error of unknown
variable "p".  need the correct logic... if i m wrong...

thanx
ravi

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c++ query

2012-01-28 Thread atul anand
abc(const char*p)

this means the string is const but pointer is not..
try this :-
//suppose intially it was p="hello"
p="world"; // this will work.
*p='e'; // compile time error


On Fri, Jan 27, 2012 at 6:08 PM, rahul sharma wrote:

> is this a type of fxn overloadingit should be allowed or not
> ?
>
>
> On Fri, Jan 27, 2012 at 4:37 PM, sukhmeet singh wrote:
>
>> they are same untill u are reading from the memory . As soon as you try
>> to modify or change .. it causes error.
>>
>> On Fri, Jan 27, 2012 at 2:32 PM, rahul sharma wrote:
>>
>>> int abc(char *);
>>> int abc(const char*);
>>>
>>> r theses same or different???...i m using dev comiler and it works..but
>>> isnt char is by default constant ???
>>>
>>> --
>>> 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.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c++ query

2012-01-27 Thread rahul sharma
is this a type of fxn overloadingit should be allowed or not
?

On Fri, Jan 27, 2012 at 4:37 PM, sukhmeet singh wrote:

> they are same untill u are reading from the memory . As soon as you try to
> modify or change .. it causes error.
>
> On Fri, Jan 27, 2012 at 2:32 PM, rahul sharma wrote:
>
>> int abc(char *);
>> int abc(const char*);
>>
>> r theses same or different???...i m using dev comiler and it works..but
>> isnt char is by default constant ???
>>
>> --
>> 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.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



  1   2   3   4   5   6   7   8   9   10   >