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 sindwani.sa...@gmail.com 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
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 deepakgarg...@gmail.com
wrote:
Hi
In example 1, member z will have a garbage value (i.e. 0 in your case )
Thanks
Deepak
On Sep 28,
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
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
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
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
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 iostream
class A
{
public:
int x,y,z;
};
int main()
{
A a1[2] =
{
{ 1,2 },
{ 3,4 }
};
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
#includeiostream
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;
coutx=this-x,y= this-y;
}
void print() { cout x =
I guess they are garbage values.
On Fri, May 31, 2013 at 3:41 PM, shubham saini shubhamsain...@gmail.comwrote:
#includeiostream
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; }
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 shubhamsain...@gmail.com wrote:
#includeiostream
using namespace std;
@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,
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
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 y.neeraj2...@gmail.comwrote:
For Dev-C++, you have
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
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
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 y.neeraj2...@gmail.comwrote:
Yes, it would be like
Ignore last to last mail. Sorry. Do show expanded content in last mail.
On 16 Nov 2012 23:49, Neeraj Gangwar y.neeraj2...@gmail.com 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
ok..thnxi got it.your r ryt n i m ryt too:)..thnx
On Fri, Nov 16, 2012 at 11:54 PM, Neeraj Gangwar y.neeraj2...@gmail.comwrote:
Ignore last to last mail. Sorry. Do show expanded content in last mail.
On 16 Nov 2012 23:49, Neeraj Gangwar y.neeraj2...@gmail.com wrote:
Yes, it would
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.comwrote:
but how
No...individually...dev cpp..how to compile both together???
On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar y.neeraj2...@gmail.comwrote:
Which compiler are you using ? Are you compiling both the files together ?
*Neeraj Gangwar*
B.Tech. IV Year
Electronics and Communication IDD
Indian
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,
@rahulsharma
file1.c
#includestdio.h
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; //
@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
Thats because you have swapped pointers and printing variables.
On Mon, Oct 29, 2012 at 11:22 PM, rahul sharma rahul23111...@gmail.comwrote:
I have taken form book...i am writing exact code
#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t;
int main()
{
float a,x;
a=20.0;
x=30.0;
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
@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,
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 vpradha...@gmail.comwrote:
@rahul : dude it's working fine ...check your printf() statement you
are swapping the pointers and printing the
@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 bansal@gmail.com wrote:
Just replace your macro with its definition and you will understand.
its not doing swapping of pointers...plz explain
@dCode i expanded..but
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
I have taken form book...i am writing exact code
#includestdio.h
#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
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
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
Why the following code is not able to swap two macros???although it is
easily swapping 2 variables
#includestdio.h
#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
it should swap
On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
Why the following code is not able to swap two macros???although it is
easily swapping 2 variables
#includestdio.h
#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);
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
Pleaase reply with sol as asp
Fille 1:
#includestdio.h
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;
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,
Then why its not running?
On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA
shobhitgupta1...@gmail.comwrote:
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
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.comwrote:
Then why its not
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
#includestdio.h
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
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 dave_and_da...@juno.com wrote:
@Bharat: 0x notation indicates hexadecimal, so 0x11 = 1*16 + 1 = 17.
Dave
On
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 bagana.bharatku...@gmail.com wrote:
how can kernel agrees with this ? if we directly access address 60 .. which
is not in our control ... any malicious thing can
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 bagana.bharatku...@gmail.com wrote:
#includestdio.h
main()
{
int *i,*j;
i=(int*)60;
j=(int*)71;
printf(%d,j-i);
}
--
You received this
(int *)60 = 60 is treated as address and 60 = 0x3c
similarly 71 = 0x47
On Sun, Oct 14, 2012 at 11:18 AM, bharat b bagana.bharatku...@gmail.comwrote:
@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
@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
#includestdio.h
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
This gives a clear explanation:
#includestdio.h
main(){
int *i,*j;
i=(int*)60;
j=(int*)71;
printf
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(%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
@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
@sachin..thnx for explanation..got it..plz tell
#includestdio.h
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
#includestdio.h
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
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
because of null char in 1st
On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma rahul23111...@gmail.comwrote:
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
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 rahul23111...@gmail.comwrote:
char str[]=ab;
char str1[]={'a','b'};
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
#includestdio.h
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 rahul23111...@gmail.comwrote:
int
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]
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
yeahu r ryt
On Tue, Jul 10, 2012 at 10:01 AM, Firoz Khursheed
firozkhursh...@gmail.comwrote:
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
he is right.
On Tue, Jul 10, 2012 at 3:13 PM, rahul sharma rahul23111...@gmail.comwrote:
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
++i/i++= 6/6
++i * i++ = 36.00
http://ideone.com/j4n0Q
On Tue, Jul 10, 2012 at 3:13 PM, rahul sharma rahul23111...@gmail.comwrote:
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
what about post increment??
On Sun, Jul 8, 2012 at 10:37 PM, mitaksh gupta mitak...@gmail.com 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 rahul23111...@gmail.comwrote:
int i=5;
i=++i/i++;
print i;
i=1
how?
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
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 firozkhursh...@gmail.comwrote:
int i=5;
i=++i/i++;
print i;
i=1
coz ++ operator in c has preference from right to left, therefor first
(i++ is
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
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.
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
Sorry, its 6/6 and not 6/5,
regds.
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com 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)
agree with adarsh
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com wrote:
Sorry, its 6/6 and not 6/5,
regds.
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com wrote:
Firstly, this is ambiguous and expressions with multiple
increment/decrement operators
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 ali.mdshau...@gmail.comwrote:
agree with adarsh
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com wrote:
Sorry, its 6/6 and
I think it should output:
9 9
On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali ali.mdshau...@gmail.comwrote:
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
ali.mdshau...@gmail.comwrote:
.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 ashishjainco...@gmail.comwrote:
I think it should output:
9 9
On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali
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
vindhyachha...@gmail.comwrote:
.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
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 vindhyachha...@gmail.com wrote:
int a=10;
int b;
b=--a--;
printf(%d %d,a,b);. l
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 atul.87fri...@gmail.com 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
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 ali.mdshau...@gmail.com wrote:
then atul what would
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 rahul23111...@gmail.comwrote:
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
violation of sequence point ruleoutput depends on compiler to compiler.
On Tue, Jul 3, 2012 at 1:22 PM, rahul sharma rahul23111...@gmail.comwrote:
#includestdio.h
#includeconio.h
int main()
{
int i;
i=5;
i=++i/i++;
printf(%d,i);
getch();
}
Why o/p is 1 and not
102 102 -90 64
On Thu, Jun 14, 2012 at 10:48 AM, Anika Jain anika.jai...@gmail.com 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
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
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
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
use gSOAP
On Tue, Jun 12, 2012 at 5:24 AM, rgap rgap...@gmail.com 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
i didn't got .. !! please explain some more..
On 2/7/12, sumit mahamuni sumit143smail...@gmail.com 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
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
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
@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
i have a confusion in it
#include stdio.h
#include stdlib.h
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
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 ravi.cool2...@gmail.com wrote:
i have a
http://www.geeksforgeeks.org/archives/14268
On Tue, Feb 7, 2012 at 1:06 AM, gmagog...@gmail.com gmagog...@gmail.comwrote:
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
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
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 rahul23111...@gmail.comwrote:
is this a type of fxn overloadingit
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
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 rahul23111...@gmail.comwrote:
int abc(char *);
int abc(const char*);
r theses same or different???...i m using dev comiler and it
is this a type of fxn overloadingit should be allowed or not
?
On Fri, Jan 27, 2012 at 4:37 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:
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,
#includestdio.h
#includeconio.h
void fun(char **);
int main()
{
char *argv[]={ab,cd,de,fg};
fun(argv);
getch();
return 0;
}
void fun(char **p)
{
char *t;
t=(p+=sizeof(int))[-1];
printf(%s\n,t);
}
o/p: fg
can nyone xplain
the 2nd statement in fun?
--
You
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
btw your compiler has sizeof(int)=4;
thats why o/p = fg
On Thu, Jan 26, 2012 at 11:09 PM, atul anand atul.87fri...@gmail.comwrote:
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.
[-1] in end is same as -1 ??
On Thu, Jan 26, 2012 at 11:11 PM, atul anand atul.87fri...@gmail.comwrote:
btw your compiler has sizeof(int)=4;
thats why o/p = fg
On Thu, Jan 26, 2012 at 11:09 PM, atul anand atul.87fri...@gmail.comwrote:
output depends on sizeof(int)so it may be
1 - 100 of 882 matches
Mail list logo