Re: Recursive functions



Harry wrote:
Hi all,

1)I need your help to solve a problem.
I have a function whose prototype is

int reclen(char *)

This function has to find the length of the string passed to it.But
the conditions are that no local variable or global variable should be
used.I have to use recursive functions.

#include <string.h>
int reclen(char *s) { return strlen(s); }

no recursive functions are needed.

2)sizeof(int) is 2 bytes in turboC.It is 4 bytes in case of gcc.why
different compilers allocate different amount of memory?what is the
reason behind it?

Because different architectures and different compiler strategies lead to different sizes and forms of pointers.

.



Relevant Pages

  • Re: Recursive functions
    ... I have a function whose prototype is ... int reclen ... used.I have to use recursive functions. ... Ask your instructor what the function should do if its ...
    (comp.lang.c)
  • Re: Recursive functions
    ... I have a function whose prototype is ... int reclen ... should be used.I have to use recursive functions. ... Ask your instructor what the function should do if its argument ...
    (comp.lang.c)
  • Re: Recursive functions
    ... I have a function whose prototype is ... int reclen ... Ask your instructor what the function should do if its ... This is as good as anything to teach the basics of recursive functions. ...
    (comp.lang.c)
  • Re: Recursive functions
    ... I have a function whose prototype is ... int reclen ... used.I have to use recursive functions. ... Ask your instructor what the function should do if its ...
    (comp.lang.c)
  • Re: Urgent C Questions
    ... int, not void. ... Then you need to turn up the warning level on QuickC. ... 3  missing prototype for 'main' ... stdio.h contains the declaration for printf: ...
    (comp.lang.c)