Re: [algogeeks] Segmentation fault with vfork

2011-10-01 Thread Amol Sharma
anyone with better explanation ??.it's still not clear to me :(
--


Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
 http://gplus.to/amolsharma99
http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





On Wed, Sep 21, 2011 at 6:34 PM, Azhar Hussain azhar...@gmail.com wrote:

 Read this documentation
 http://pubs.opengroup.org/onlinepubs/7908799/xsh/vfork.html

 vfork creates read-only copy of the parent. You cannot call function or
 assign value to variable except pid_t. Use fork and it should succeed.

 PS: Please ask questions related to Algorithms, as it is algorithm group.
 You could get fast answers for this type of question on a relevant group. No
 offense, it is just a advice. It could save time for other people and YOU
 too.

 -
 Azhar.


 On Wed, Sep 21, 2011 at 6:23 PM, sukran dhawan sukrandha...@gmail.comwrote:

  @sreeu :lol #includestdio.h? :P include this header file:P
 That s not saurabh s question

 On Wed, Sep 21, 2011 at 4:51 PM, SREENU NAIK srinivasulunai...@gmail.com
  wrote:


 hi it gives that


 in fun1:incompatible implicit declaration of built-in function ‘printf’

  in fun2:incompatible implicit declaration of built-in function ‘printf’


 On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh saurab...@gmail.comwrote:

 #includesys/types.h
 int fun1()
 {
 if(vfork()==0);
 else printf(Fun1\n);
 }
 int fun2()
 {
 printf(Fun2\n);
 }
 int main()
 {
 fun1();
 fun2();
 return 0;
 }
 Why does this program giving seg fault.?

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


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


-- 
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] Segmentation fault with vfork

2011-10-01 Thread Amol Sharma
similar question...also gives segmentation fault...plz explain...
http://ideone.com/nlpzT

#includeunistd.h#includefcntl.h#includestdio.h
 int main()
 {
  int pid;
  printf 
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(Parent\n);
  pid = vfork();
  if(pid==0)
  {
  printf
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(Child\n);
  }
  return 0;
  }


--


Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
 http://gplus.to/amolsharma99
http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





On Sat, Oct 1, 2011 at 1:15 PM, Amol Sharma amolsharm...@gmail.com wrote:

 anyone with better explanation ??.it's still not clear to me :(
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad
  http://gplus.to/amolsharma99 
 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





 On Wed, Sep 21, 2011 at 6:34 PM, Azhar Hussain azhar...@gmail.com wrote:

 Read this documentation
 http://pubs.opengroup.org/onlinepubs/7908799/xsh/vfork.html

 vfork creates read-only copy of the parent. You cannot call function or
 assign value to variable except pid_t. Use fork and it should succeed.

 PS: Please ask questions related to Algorithms, as it is algorithm group.
 You could get fast answers for this type of question on a relevant group. No
 offense, it is just a advice. It could save time for other people and YOU
 too.

 -
 Azhar.


 On Wed, Sep 21, 2011 at 6:23 PM, sukran dhawan sukrandha...@gmail.comwrote:

  @sreeu :lol #includestdio.h? :P include this header file:P
 That s not saurabh s question

 On Wed, Sep 21, 2011 at 4:51 PM, SREENU NAIK 
 srinivasulunai...@gmail.com wrote:


 hi it gives that


 in fun1:incompatible implicit declaration of built-in function ‘printf’

  in fun2:incompatible implicit declaration of built-in function ‘printf’


 On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh saurab...@gmail.comwrote:

 #includesys/types.h
 int fun1()
 {
 if(vfork()==0);
 else printf(Fun1\n);
 }
 int fun2()
 {
 printf(Fun2\n);
 }
 int main()
 {
 fun1();
 fun2();
 return 0;
 }
 Why does this program giving seg fault.?

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


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




-- 
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] Segmentation fault with vfork

2011-10-01 Thread saurabh singh
Both share the same address space that includes even the stack
The child *returns first clearing the stack.*Now when the parent process
tries to return the child process had already cleared the stack.SO it no
longer belongs to the parent process,so sigsegv.
Try with gdb dissassemble and step *instruction by instruction checking the
state of esp at each level.*
On Sat, Oct 1, 2011 at 1:28 PM, Amol Sharma amolsharm...@gmail.com wrote:

 similar question...also gives segmentation fault...plz explain...
 http://ideone.com/nlpzT

 #includeunistd.h#includefcntl.h#includestdio.h
  int main()
  {
   int pid;
   printf 
 http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(Parent\n);
   pid = vfork();
   if(pid==0)
   {
   printf 
 http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(Child\n);
   }
   return 0;
   }


 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad
  http://gplus.to/amolsharma99 
 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





 On Sat, Oct 1, 2011 at 1:15 PM, Amol Sharma amolsharm...@gmail.comwrote:

 anyone with better explanation ??.it's still not clear to me :(
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad
  http://gplus.to/amolsharma99 
 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





 On Wed, Sep 21, 2011 at 6:34 PM, Azhar Hussain azhar...@gmail.comwrote:

 Read this documentation
 http://pubs.opengroup.org/onlinepubs/7908799/xsh/vfork.html

 vfork creates read-only copy of the parent. You cannot call function or
 assign value to variable except pid_t. Use fork and it should succeed.

 PS: Please ask questions related to Algorithms, as it is algorithm group.
 You could get fast answers for this type of question on a relevant group. No
 offense, it is just a advice. It could save time for other people and YOU
 too.

 -
 Azhar.


 On Wed, Sep 21, 2011 at 6:23 PM, sukran dhawan 
 sukrandha...@gmail.comwrote:

  @sreeu :lol #includestdio.h? :P include this header file:P
 That s not saurabh s question

 On Wed, Sep 21, 2011 at 4:51 PM, SREENU NAIK 
 srinivasulunai...@gmail.com wrote:


 hi it gives that


 in fun1:incompatible implicit declaration of built-in function ‘printf’

  in fun2:incompatible implicit declaration of built-in function
 ‘printf’


 On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh saurab...@gmail.comwrote:

 #includesys/types.h
 int fun1()
 {
 if(vfork()==0);
 else printf(Fun1\n);
 }
 int fun2()
 {
 printf(Fun2\n);
 }
 int main()
 {
 fun1();
 fun2();
 return 0;
 }
 Why does this program giving seg fault.?

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


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



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




-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD

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

Re: [algogeeks] Segmentation fault with vfork

2011-10-01 Thread Amol Sharma
thnx saurabh.u rock :)
--


Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
 http://gplus.to/amolsharma99
http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





On Sat, Oct 1, 2011 at 4:55 PM, saurabh singh saurab...@gmail.com wrote:


 Both share the same address space that includes even the stack
 The child *returns first clearing the stack.*Now when the parent process
 tries to return the child process had already cleared the stack.SO it no
 longer belongs to the parent process,so sigsegv.
 Try with gdb dissassemble and step *instruction by instruction checking
 the state of esp at each level.*

 On Sat, Oct 1, 2011 at 1:28 PM, Amol Sharma amolsharm...@gmail.comwrote:

 similar question...also gives segmentation fault...plz explain...
 http://ideone.com/nlpzT

 #includeunistd.h#includefcntl.h#includestdio.h
  int main()
  {
   int pid;
   printf 
 http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(Parent\n);
   pid = vfork();
   if(pid==0)
   {
   printf 
 http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(Child\n);
   }
   return 0;
   }


 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad
  http://gplus.to/amolsharma99 
 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





 On Sat, Oct 1, 2011 at 1:15 PM, Amol Sharma amolsharm...@gmail.comwrote:

 anyone with better explanation ??.it's still not clear to me :(
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad
  http://gplus.to/amolsharma99 
 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





 On Wed, Sep 21, 2011 at 6:34 PM, Azhar Hussain azhar...@gmail.comwrote:

 Read this documentation
 http://pubs.opengroup.org/onlinepubs/7908799/xsh/vfork.html

 vfork creates read-only copy of the parent. You cannot call function or
 assign value to variable except pid_t. Use fork and it should succeed.

 PS: Please ask questions related to Algorithms, as it is algorithm
 group. You could get fast answers for this type of question on a relevant
 group. No offense, it is just a advice. It could save time for other people
 and YOU too.

 -
 Azhar.


 On Wed, Sep 21, 2011 at 6:23 PM, sukran dhawan 
 sukrandha...@gmail.comwrote:

  @sreeu :lol #includestdio.h? :P include this header file:P
 That s not saurabh s question

 On Wed, Sep 21, 2011 at 4:51 PM, SREENU NAIK 
 srinivasulunai...@gmail.com wrote:


 hi it gives that


 in fun1:incompatible implicit declaration of built-in function
 ‘printf’

  in fun2:incompatible implicit declaration of built-in function
 ‘printf’


 On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh 
 saurab...@gmail.comwrote:

 #includesys/types.h
 int fun1()
 {
 if(vfork()==0);
 else printf(Fun1\n);
 }
 int fun2()
 {
 printf(Fun2\n);
 }
 int main()
 {
 fun1();
 fun2();
 return 0;
 }
 Why does this program giving seg fault.?

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


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



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

Re: [algogeeks] Segmentation fault with vfork

2011-09-21 Thread SREENU NAIK
hi it gives that


in fun1:incompatible implicit declaration of built-in function ‘printf’

 in fun2:incompatible implicit declaration of built-in function ‘printf’

On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh saurab...@gmail.com wrote:

 #includesys/types.h
 int fun1()
 {
 if(vfork()==0);
 else printf(Fun1\n);
 }
 int fun2()
 {
 printf(Fun2\n);
 }
 int main()
 {
 fun1();
 fun2();
 return 0;
 }
 Why does this program giving seg fault.?

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


  --
 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] Segmentation fault with vfork

2011-09-21 Thread sukran dhawan
 @sreeu :lol #includestdio.h? :P include this header file:P
That s not saurabh s question
On Wed, Sep 21, 2011 at 4:51 PM, SREENU NAIK srinivasulunai...@gmail.comwrote:


 hi it gives that


 in fun1:incompatible implicit declaration of built-in function ‘printf’

  in fun2:incompatible implicit declaration of built-in function ‘printf’


 On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh saurab...@gmail.comwrote:

 #includesys/types.h
 int fun1()
 {
 if(vfork()==0);
 else printf(Fun1\n);
 }
 int fun2()
 {
 printf(Fun2\n);
 }
 int main()
 {
 fun1();
 fun2();
 return 0;
 }
 Why does this program giving seg fault.?

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


  --
 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] Segmentation fault with vfork

2011-09-21 Thread Azhar Hussain
Read this documentation
http://pubs.opengroup.org/onlinepubs/7908799/xsh/vfork.html

vfork creates read-only copy of the parent. You cannot call function or
assign value to variable except pid_t. Use fork and it should succeed.

PS: Please ask questions related to Algorithms, as it is algorithm group.
You could get fast answers for this type of question on a relevant group. No
offense, it is just a advice. It could save time for other people and YOU
too.

-
Azhar.

On Wed, Sep 21, 2011 at 6:23 PM, sukran dhawan sukrandha...@gmail.comwrote:

  @sreeu :lol #includestdio.h? :P include this header file:P
 That s not saurabh s question

 On Wed, Sep 21, 2011 at 4:51 PM, SREENU NAIK 
 srinivasulunai...@gmail.comwrote:


 hi it gives that


 in fun1:incompatible implicit declaration of built-in function ‘printf’

  in fun2:incompatible implicit declaration of built-in function ‘printf’


 On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh saurab...@gmail.comwrote:

 #includesys/types.h
 int fun1()
 {
 if(vfork()==0);
 else printf(Fun1\n);
 }
 int fun2()
 {
 printf(Fun2\n);
 }
 int main()
 {
 fun1();
 fun2();
 return 0;
 }
 Why does this program giving seg fault.?

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


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



[algogeeks] Segmentation fault with vfork

2011-09-20 Thread saurabh singh
#includesys/types.h
int fun1()
{
if(vfork()==0);
else printf(Fun1\n);
}
int fun2()
{
printf(Fun2\n);
}
int main()
{
fun1();
fun2();
return 0;
}
Why does this program giving seg fault.?

-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD

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



[algogeeks] Segmentation fault

2011-06-23 Thread harshit pahuja

this is ma code for http://www.spoj.pl/problems/ANARC08H/musical
chairs
i m using dynamic programming

for input lik
20 20
i m getting seg. fault
plz tell hw to modify  my program



#includeiostream
#includecstdio
using namespace std;

long long arr[10003][10003];

long long f(int n,int k)

{
if(n==1) return 0;
else {
//if(arr[n][k]) return arr[n][k];
return /* arr[n][k] = */(f(n-1,k)+k)%n ;
}

}


int main()
{
int n,k;
scanf(%d%d,n,k);
//cinnk;
while(n  k)
{
printf(%d %d %lld\n,n,k,f(n,k)+1);
//coutf(n,k)+1;
scanf(%d%d,n,k);
}
return 0;
}

-- 
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] Segmentation fault

2011-06-23 Thread piyush kapoor
You are using too much memory :: long long arr[10003][10003];

-- 
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] Segmentation fault

2011-06-23 Thread harshit pahuja
@piyush
using array is mecessary as constraints are n,d100
so recursion cannot go to that much depth as we have stack limits

what do u suggest

-- 
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] Segmentation fault

2011-06-23 Thread harshit pahuja
got it

:)  AC

used single array nd got the job done..

On Thu, Jun 23, 2011 at 4:22 AM, harshit pahuja hpahuja.mn...@gmail.comwrote:

 @piyush
 using array is mecessary as constraints are n,d100
 so recursion cannot go to that much depth as we have stack limits

 what do u suggest




-- 
HARSHIT PAHUJA
M.N.N.I.T.
ALLAHABAD

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