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

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 speci

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

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 sp

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, "saga

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

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 f

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

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: >

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)

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

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 to

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 o

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 varia

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 exte

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

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 R

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; // dec

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

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 Techno

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

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 th

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

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,

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

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 M

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

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

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

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

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

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 t

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 th

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 receiv

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, Oc

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/definitio

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, c

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:

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 cons

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 subs

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: Facebo

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

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, 201

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 wher

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 =

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, Oc

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, 20

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??

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 fr

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 l

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

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 st

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 > "Alg

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 >

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

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/87w

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

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

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 u

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 m

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

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 thi

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 pr

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

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

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, ashis

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

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

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,

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

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

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:2

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

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

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" a

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

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.c

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

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

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

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 vari

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. > > Co

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 > > #incl

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

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

Re: [algogeeks] c++ query

2012-01-27 Thread sukhmeet singh
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 i

Re: [algogeeks] C o/p help

2012-01-26 Thread rahul sharma
@ atul...got nw..thnx On Thu, Jan 26, 2012 at 11:26 PM, atul anand wrote: > think in terms of pointers... > > they are same :- > > p[-1] = *(p - 1) > > > On Thu, Jan 26, 2012 at 11:15 PM, rahul sharma wrote: > >> [-1] in end is same as -1 ?? >> >> >> On Thu, Jan 26, 2012 at 11:11 PM, atul ana

Re: [algogeeks] C o/p help

2012-01-26 Thread atul anand
think in terms of pointers... they are same :- p[-1] = *(p - 1) On Thu, Jan 26, 2012 at 11:15 PM, rahul sharma wrote: > [-1] in end is same as -1 ?? > > > On Thu, Jan 26, 2012 at 11:11 PM, atul anand wrote: > >> btw your compiler has sizeof(int)=4; >> thats why o/p = fg >> >> On Thu, Jan 26

Re: [algogeeks] C o/p help

2012-01-26 Thread rahul sharma
[-1] in end is same as -1 ?? On Thu, Jan 26, 2012 at 11:11 PM, atul anand wrote: > btw your compiler has sizeof(int)=4; > thats why o/p = fg > > On Thu, Jan 26, 2012 at 11:09 PM, atul anand wrote: > >> output depends on sizeof(int)so it may be different if you run on >> different compiler

Re: [algogeeks] C o/p help

2012-01-26 Thread atul anand
btw your compiler has sizeof(int)=4; thats why o/p = fg On Thu, Jan 26, 2012 at 11:09 PM, atul anand wrote: > output depends on sizeof(int)so it may be different if you run on > different compilers. > > considering *sizeof(int) = 2;* > > argv[] is array of pointers. > (p+=sizeof(int))[-1];

Re: [algogeeks] C o/p help

2012-01-26 Thread atul anand
output depends on sizeof(int)so it may be different if you run on different compilers. considering *sizeof(int) = 2;* argv[] is array of pointers. (p+=sizeof(int))[-1]; p=p+2 // 2=sizeof(int); now p will be pointing at index *argv[2]; then you are doing p=p-1; i.e p will point to *ar

Re: [algogeeks] c++_Output

2012-01-21 Thread priyanka jaggi
i=i++ + ++i; j++ + ++j; k=k++ + k++ + ++k; All these Statements have compiler Dependent Output, As they violet sequence point rule ( here value of a variable is modified two or more times between two successive sequence points.) Standard does not specify the exact order of execution of these type

Re: [algogeeks] c++_Output

2012-01-21 Thread atul anand
output is complier dependent . On Sat, Jan 21, 2012 at 5:12 PM, Kailash Bagaria wrote: > Please explain the output of the following program > > #include > using namespace std; > int main() > { > int i=5; > i=i++ + ++i; > cout< > int j=5; > cout< > int k=5; >

Re: [algogeeks] c output

2012-01-16 Thread payal gupta
i gues atul is crkt. its jst printin by user convenience...when actually d two are not equal... i guess the code...xplains well...dats y "equal " is not printed..out #includeint main(){ double p=fabs(24.9996); printf("%lf\n",p); double t=fabs(25.0003); printf("%lf\n",t); print

Re: [algogeeks] c output

2012-01-16 Thread Rujin Cao
It's not a good way to compare two floats directly using =, try something like below: http://ideone.com/c65Vl -- 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 fro

Re: [algogeeks] c output

2012-01-16 Thread shady
atul he is assigning the value later on. i think format specifier . rounds up the number in last decimal place. On Tue, Jan 17, 2012 at 11:53 AM, atul anand wrote: > printf("%0.3lf %0.3lf\n",p,t); > > its just printing at your convenience . you are not changing the value of > p,t . > change this

Re: [algogeeks] c output

2012-01-16 Thread atul anand
printf("%0.3lf %0.3lf\n",p,t); its just printing at your convenience . you are not changing the value of p,t . change this statement to printf("%0.5lf %0.5lf\n",p,t); On Tue, Jan 17, 2012 at 11:27 AM, dabbcomputers wrote: > #include > int main() > { >double p=fabs(24.9996); >double t=f

Re: [algogeeks] C QUESTION???

2012-01-10 Thread Rahul Verma
thanks for the info -- 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/-/E1c87OjP6LAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubs

Re: [algogeeks] c output ??

2012-01-10 Thread saurabh singh
It's painful to see printf being accused for the (un) expected output..The declaration of printf means that any data type can be passed to it as argument.Inherently what printf does is print the bytes in meaningful form according to the first argument which is a string.So its impossible for pri

Re: [algogeeks] c output ??

2012-01-10 Thread Rahul Verma
@amol this is not the behaviour of printf, its totally about the typecasting -- 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/-/GPVlt15S3V0J. To post to this g

  1   2   3   4   5   6   7   8   >