C pointer

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2009
Posts: 3
Reputation: chet6 is an unknown quantity at this point 
Solved Threads: 0
chet6 chet6 is offline Offline
Newbie Poster

C pointer

 
1
  #1
26 Days Ago
Hi,
Could anyone please explain how the memory allocatio is done in case of double pointers?
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 76
Reputation: Gaiety is an unknown quantity at this point 
Solved Threads: 2
Gaiety's Avatar
Gaiety Gaiety is offline Offline
Junior Poster in Training
 
1
  #2
26 Days Ago
Originally Posted by chet6 View Post
Hi,
Could anyone please explain how the memory allocatio is done in case of double pointers?

int var = 10 ;
int *pvar = &var;
int **ppvar = &pvar;

here var is 10. and this will be stored in some memory say that is
1000 (i.e &var =1000)
so
var =10
&var =1000

to store &var we need a pointer ,
so we declared variable pvar then stored &var 1000 in that

so
pvar = 1000
now pvar is also a variable it also stores at some location
say that is 2000
&pvar = 2000
now i want to store the address of a poiner variable i require a pointer to pointer .
so i declared ppvar
hence
ppvar =&pvar,
now
ppvar is also a variable so it also gets some memory so lets say that is 3000
so
ppvar = 2000
&ppvar = 3000

now if i want to access either var or pvar i can do that by using ppvar
say

printf(" %u",var);
printf(" %u\n",*pvar);
printf(" %u\n",**ppvar);
all gives you only 10

printf(" %u\n",&var);
printf(" %u\n",ppvar);
printf(" %u\n",*ppvar);
gives you 1000

printf(" %u\n",&ppvar);
printf(" %u\n",ppvar);
gives you 2000
printf(" %u\n", &ppvar);
gives you 3000.

the results may vary taken just for simplicity
Minds are like parachutes - they only work when they are open
Gaiety
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: chet6 is an unknown quantity at this point 
Solved Threads: 0
chet6 chet6 is offline Offline
Newbie Poster
 
0
  #3
25 Days Ago
Thanks for the reply.Its clear now.I want to build a small project in c which includes both graphics and pointer concepts using LINUX OS.Could you please let me know how can i proceed on this?
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 50
Reputation: Iam3R is an unknown quantity at this point 
Solved Threads: 3
Iam3R Iam3R is offline Offline
Junior Poster in Training
 
0
  #4
24 Days Ago
Originally Posted by chet6 View Post
Thanks for the reply.Its clear now.I want to build a small project in c which includes both graphics and pointer concepts using LINUX OS.Could you please let me know how can i proceed on this?

pointers and graphics:
no good idea:
may be you can start learning ncurses and try with them
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: chet6 is an unknown quantity at this point 
Solved Threads: 0
chet6 chet6 is offline Offline
Newbie Poster
 
0
  #5
23 Days Ago
Originally Posted by Iam3R View Post
pointers and graphics:
no good idea:
may be you can start learning ncurses and try with them
Thanx but i want to improve knowledge on C with pointer.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 4
Reputation: uskok is an unknown quantity at this point 
Solved Threads: 1
uskok uskok is offline Offline
Newbie Poster
 
0
  #6
22 Days Ago
Originally Posted by Gaiety View Post
printf(" %u\n",&ppvar);
... gives you 2000
You have one 'p' too many. :)
printf(" %u\n",&ppvar); //prints 3000
printf(" %u\n",&pvar); //prints 2000
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 17
Reputation: manutm is an unknown quantity at this point 
Solved Threads: 1
manutm manutm is offline Offline
Newbie Poster
 
1
  #7
21 Days Ago
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 50
Reputation: Iam3R is an unknown quantity at this point 
Solved Threads: 3
Iam3R Iam3R is offline Offline
Junior Poster in Training
 
0
  #8
19 Days Ago
Originally Posted by manutm View Post
http://www.libsdl.org/cgi/docwiki.cgi/

Thank you so very muchhh manutm..

its really good.

is it like the gstreamer or any way diffrent? which is most popular and has high demand in terms of job opportunities.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 17
Reputation: manutm is an unknown quantity at this point 
Solved Threads: 1
manutm manutm is offline Offline
Newbie Poster
 
0
  #9
18 Days Ago
SDL is mainly for game development (and sometimes for other multimedia stuff as well) and is quite popular I think. Now, it depends on what kind of job you are looking for... If you are interested in making applications with GUI under Linux, I think GTK is very good. For 3D stuff, OpenGL is probably a "must-known", etc...
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC