RE: [Dev-C++] Question about pointers (beginner)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Smurf, P. <smu...@xs...> - 2003-05-27 19:09:37
|
Ok you are correct however. But I was looking for the value of x or even
*ptr_int not ptr_int.
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of Felipe
> Lima
> Sent: dinsdag 27 mei 2003 20:51
> To: dev...@li...
> Subject: Fw: [Dev-C++] Question about pointers (beginner)
>
>
> When you say *ptr = &variable, you are assigning the memory address of the
> variable to the pointer, not the variable's real value(123).
> So the final value of ptr_int would be the memory address of the
> variable(x), which is unknown for us, only the program knows.
>
>
> -=-=-=-=-=-=-
> Felipe Lima - Software Tester/ Developer
> CPTS - Software Test Research Center
> HP Brazil - PUCRS
> ----- Original Message -----
> From: "Christian Schmidt" <sm...@xs...>
> To: <dev...@li...>
> Sent: Tuesday, May 27, 2003 3:17 PM
> Subject: [Dev-C++] Question about pointers (beginner)
>
>
> > >From my book:
> >
> > Given x = 123 and ptr_int = &x after that *ptr_int = 456 has been
> executed.
> > What is the value of x?
> >
> > I thought it was 123 as the pointer *ptr_int is a null pointer and can't
> > have any value.
> >
> > This is how I see it:
> >
> > main ( )
> > {
> > int x, *ptr_int;
> >
> > *ptr_int = 456; /*This pointer is a null pointer at this moment
> right? */
> >
> > x =123;
> > ptr_int = &x; /* As x is just set to 123 and the statement
> *ptr_int = 456;
> > was executed before I would think *ptr_int would be 123 */
> >
> > }
> >
> > ----------
> >
> > But the books says the value of *ptr_int at the end is 456. How come??
> >
> > Thanks for your time,
> >
> > Christian
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: ObjectStore.
> > If flattening out C++ or Java code to make your application fit in a
> > relational database is painful, don't do it! Check out ObjectStore.
> > Now part of Progress Software. http://www.objectstore.net/sourceforge
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> >
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ObjectStore.
> If flattening out C++ or Java code to make your application fit in a
> relational database is painful, don't do it! Check out ObjectStore.
> Now part of Progress Software. http://www.objectstore.net/sourceforge
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|