Re: [algogeeks] Small Doubt
@Prem: Each program is provided with a pool of address, which consist of heap, stack etc. My question is that if I write an address 0xff which is not provided to that program then what will be the output? On 7/28/11, Prem Krishna Chettri hprem...@gmail.com wrote: First of all this is a good Question as this is use regularly in Device Driver kind of Development Mode and hence there is no question of Not Possible. So how to Do it is Question. which is as follows :- Point your pointer to mem add that U want and Now this Mem Add is HEX guys (Not 4 or 5 or any base 10 val) , so put it as 0x(whatever U want). Do whatever U want to do on that address using that pointer now. The Code above is correct but the implementation is wrong so... #includestdio.h int main() { int *p = (int *)0xff; // *p = 4; /** Dude can U put hex val here .. Oh its already assigned to 0xff.. **/ Now print it coutpendl; return 0; } Regards Prem On Thu, Jul 28, 2011 at 10:44 AM, Tyler Durden abhishek.khattr...@gmail.com wrote: @Ankita: So when is 4000 memory address is allotted?? I mean what use does int *p = 4000 serve here?? -- 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/-/0OU6tMQudMoJ. 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] Small Doubt
Hey.. good To have your Question . Well lemme try to elaborate things here as i cannot use WhiteBoard . So Srry guys... :( Well partly you have answered your question and some part can even be reflected in the above thread of virtual - physical mem mapping. using MMU.. So I wont go beyond MMU. Here it goes. Well if you write a prg.. when it bcme process, OS assign a bunch of ID as Address which it can use in sense. However, this address are not what is real add.there is what MMU kicks in... So if 0xff U think is assigned its not actually its is mapped with something like this .. PID + 0x0ff = xyzxyx( Hell anything let the OS answer it). that MMU issue. So, the question here is wat the case if the house you want is not in your area. Dude you are not a kind to cry infront of your parent to get one for U.. Similarly, OS will not give you the access directly to physical Mem ( under his control ) hence, the pointer allocation may fail. Now here comes the compiler of whatever type say g++ which may silently say dude that house you want is unavailable or may keep quiet... but complains when you are in need to stay in that house , or rather when you try to put something within it. So, the direct answer to your question is definitely your design of Compiler. but rather I would like to say, the pointer allocation fails to prove your address allocation. Does that makes sense. lemme know for more without whiteboard.. :) Regards Prem On Thu, Jul 28, 2011 at 1:26 PM, MANNU manishkr2...@gmail.com wrote: @Prem: Each program is provided with a pool of address, which consist of heap, stack etc. My question is that if I write an address 0xff which is not provided to that program then what will be the output? On 7/28/11, Prem Krishna Chettri hprem...@gmail.com wrote: First of all this is a good Question as this is use regularly in Device Driver kind of Development Mode and hence there is no question of Not Possible. So how to Do it is Question. which is as follows :- Point your pointer to mem add that U want and Now this Mem Add is HEX guys (Not 4 or 5 or any base 10 val) , so put it as 0x(whatever U want). Do whatever U want to do on that address using that pointer now. The Code above is correct but the implementation is wrong so... #includestdio.h int main() { int *p = (int *)0xff; // *p = 4; /** Dude can U put hex val here .. Oh its already assigned to 0xff.. **/ Now print it coutpendl; return 0; } Regards Prem On Thu, Jul 28, 2011 at 10:44 AM, Tyler Durden abhishek.khattr...@gmail.com wrote: @Ankita: So when is 4000 memory address is allotted?? I mean what use does int *p = 4000 serve here?? -- 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/-/0OU6tMQudMoJ. 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] Small Doubt
no we cant.. coz when we do say int *p=4000; its fine till now.. and if we do *p=10; it is segmentation fault.. On Wed, Jul 27, 2011 at 10:35 PM, rShetty rajeevr...@gmail.com wrote: Usually when I declare a variable it will be stored in memory location with some address . Such as consider I declare int x=10 , it will stored in some address 1003 (say). Now my question is can I control the address being assigned to a variable in C . Say, I want to store x in address in 4000 and not in 1003 defined by the compiler .(Usually this can be done in assembly). Can I do that ? Correct me If i am wrong -- 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] Small Doubt
segmentation fault comes when we try to modify or do illegal access to the memory that has not been allocated to us.. the trial to make your variable be at some location of your wish can be done only by int *p=4000; *p=10; but it is illegal coz 4000 memory address is not alloted yet for your program. On Wed, Jul 27, 2011 at 11:26 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @Anika : pls elaborate the segmentatin part...! On 7/27/11, Anika Jain anika.jai...@gmail.com wrote: no we cant.. coz when we do say int *p=4000; its fine till now.. and if we do *p=10; it is segmentation fault.. On Wed, Jul 27, 2011 at 10:35 PM, rShetty rajeevr...@gmail.com wrote: Usually when I declare a variable it will be stored in memory location with some address . Such as consider I declare int x=10 , it will stored in some address 1003 (say). Now my question is can I control the address being assigned to a variable in C . Say, I want to store x in address in 4000 and not in 1003 defined by the compiler .(Usually this can be done in assembly). Can I do that ? Correct me If i am wrong -- 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] Small Doubt
@anika : I just found out that it can be done as int *p = (int *)0x0ff ; *p=4; then 4 gets stored in 0x0ff location . Guys can it be done . Is it Legal ?? On Thu, Jul 28, 2011 at 9:11 AM, Anika Jain anika.jai...@gmail.com wrote: segmentation fault comes when we try to modify or do illegal access to the memory that has not been allocated to us.. the trial to make your variable be at some location of your wish can be done only by int *p=4000; *p=10; but it is illegal coz 4000 memory address is not alloted yet for your program. On Wed, Jul 27, 2011 at 11:26 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @Anika : pls elaborate the segmentatin part...! On 7/27/11, Anika Jain anika.jai...@gmail.com wrote: no we cant.. coz when we do say int *p=4000; its fine till now.. and if we do *p=10; it is segmentation fault.. On Wed, Jul 27, 2011 at 10:35 PM, rShetty rajeevr...@gmail.com wrote: Usually when I declare a variable it will be stored in memory location with some address . Such as consider I declare int x=10 , it will stored in some address 1003 (say). Now my question is can I control the address being assigned to a variable in C . Say, I want to store x in address in 4000 and not in 1003 defined by the compiler .(Usually this can be done in assembly). Can I do that ? Correct me If i am wrong -- 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. -- Regards Rajeev N B http://www.opensourcemania.co.cc *Winners Don't do Different things , they do things Differently* -- 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] Small Doubt
@ rajeev, vishal@ubuntu:~/progs/c\ 09:25:38 AM $ cat alg.c #includestdio.h int main() { int *p = (int *)0xff; *p = 4; return 0; } vishal@ubuntu:~/progs/c\ 09:25:42 AM $ gcc alg.c vishal@ubuntu:~/progs/c\ 09:25:45 AM $ ./a.out Segmentation fault vishal@ubuntu:~/progs/c\ 09:25:46 AM $ On Thu, Jul 28, 2011 at 9:13 AM, rajeev bharshetty rajeevr...@gmail.com wrote: @anika : I just found out that it can be done as int *p = (int *)0x0ff ; *p=4; then 4 gets stored in 0x0ff location . Guys can it be done . Is it Legal ?? On Thu, Jul 28, 2011 at 9:11 AM, Anika Jain anika.jai...@gmail.com wrote: segmentation fault comes when we try to modify or do illegal access to the memory that has not been allocated to us.. the trial to make your variable be at some location of your wish can be done only by int *p=4000; *p=10; but it is illegal coz 4000 memory address is not alloted yet for your program. On Wed, Jul 27, 2011 at 11:26 PM, Puneet Gautam puneet.nsi...@gmail.com wrote: @Anika : pls elaborate the segmentatin part...! On 7/27/11, Anika Jain anika.jai...@gmail.com wrote: no we cant.. coz when we do say int *p=4000; its fine till now.. and if we do *p=10; it is segmentation fault.. On Wed, Jul 27, 2011 at 10:35 PM, rShetty rajeevr...@gmail.com wrote: Usually when I declare a variable it will be stored in memory location with some address . Such as consider I declare int x=10 , it will stored in some address 1003 (say). Now my question is can I control the address being assigned to a variable in C . Say, I want to store x in address in 4000 and not in 1003 defined by the compiler .(Usually this can be done in assembly). Can I do that ? Correct me If i am wrong -- 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. -- Regards Rajeev N B Winners Don't do Different things , they do things Differently -- 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] Small Doubt
whether al these address refer to the physical address or logical address??? On 7/28/11, Vishal Thanki vishaltha...@gmail.com wrote: @ rajeev, vishal@ubuntu:~/progs/c\ 09:25:38 AM $ cat alg.c #includestdio.h int main() { int *p = (int *)0xff; *p = 4; return 0; } vishal@ubuntu:~/progs/c\ 09:25:42 AM $ gcc alg.c vishal@ubuntu:~/progs/c\ 09:25:45 AM $ ./a.out Segmentation fault vishal@ubuntu:~/progs/c\ 09:25:46 AM $ On Thu, Jul 28, 2011 at 9:13 AM, rajeev bharshetty rajeevr...@gmail.com wrote: @anika : I just found out that it can be done as int *p = (int *)0x0ff ; *p=4; then 4 gets stored in 0x0ff location . Guys can it be done . Is it Legal ?? On Thu, Jul 28, 2011 at 9:11 AM, Anika Jain anika.jai...@gmail.com wrote: segmentation fault comes when we try to modify or do illegal access to the memory that has not been allocated to us.. the trial to make your variable be at some location of your wish can be done only by int *p=4000; *p=10; but it is illegal coz 4000 memory address is not alloted yet for your program. On Wed, Jul 27, 2011 at 11:26 PM, Puneet Gautam puneet.nsi...@gmail.com wrote: @Anika : pls elaborate the segmentatin part...! On 7/27/11, Anika Jain anika.jai...@gmail.com wrote: no we cant.. coz when we do say int *p=4000; its fine till now.. and if we do *p=10; it is segmentation fault.. On Wed, Jul 27, 2011 at 10:35 PM, rShetty rajeevr...@gmail.com wrote: Usually when I declare a variable it will be stored in memory location with some address . Such as consider I declare int x=10 , it will stored in some address 1003 (say). Now my question is can I control the address being assigned to a variable in C . Say, I want to store x in address in 4000 and not in 1003 defined by the compiler .(Usually this can be done in assembly). Can I do that ? Correct me If i am wrong -- 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. -- Regards Rajeev N B Winners Don't do Different things , they do things Differently -- 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. -- //BE COOL// kavi -- 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] Small Doubt
@Ankita: So when is 4000 memory address is allotted?? I mean what use does int *p = 4000 serve here?? -- 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/-/0OU6tMQudMoJ. 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] Small Doubt
First of all this is a good Question as this is use regularly in Device Driver kind of Development Mode and hence there is no question of Not Possible. So how to Do it is Question. which is as follows :- Point your pointer to mem add that U want and Now this Mem Add is HEX guys (Not 4 or 5 or any base 10 val) , so put it as 0x(whatever U want). Do whatever U want to do on that address using that pointer now. The Code above is correct but the implementation is wrong so... #includestdio.h int main() { int *p = (int *)0xff; // *p = 4; /** Dude can U put hex val here .. Oh its already assigned to 0xff.. **/ Now print it coutpendl; return 0; } Regards Prem On Thu, Jul 28, 2011 at 10:44 AM, Tyler Durden abhishek.khattr...@gmail.com wrote: @Ankita: So when is 4000 memory address is allotted?? I mean what use does int *p = 4000 serve here?? -- 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/-/0OU6tMQudMoJ. 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.