Re: Recursively
In article <1187512740.405085.225510@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
karthikbalaguru <karthikbalaguru79@xxxxxxxxx> wrote:
void f(char *) ;
main()
{
f("123");
}
void f(char a[])
{
if(a[1]=='\0')
return;
f(a+1);
f(a+1);
printf("%c", a[1]);
}
The output for this program has been stated as 332.
How is it possible ?
f("123") is called. It calls f("23") twice, then prints "2".
f("23") calls f("3") twice, then prints "3".
f("3") doesn't print anything.
So "3" gets printed twice, then "2".
Whether you actually see anything is system dependent, because no
linefeed is printed at the end.
-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
.
Relevant Pages
- Re: void * vs char *
... anyone ever use a void * in their code, ... char * means that it points to characters or bytes. ... "Consideration shall be given to the need for as many as 32 characters ... in some alphabets" - X3.4, ... (comp.lang.c) - Re: Is continuum completely filled up?
... Therfore real line has void. ... distance from every other point mean that there are gaps? ... "Consideration shall be given to the need for as many as 32 characters ... in some alphabets" - X3.4, ... (sci.math) - Re: Is continuum completely filled up?
... Therfore real line has void. ... distance from every other point mean that there are gaps? ... "Consideration shall be given to the need for as many as 32 characters ... in some alphabets" - X3.4, ... (sci.math) - Re: Please help with this.
... returns a CString. ... it also seems possible you will drop characters by ... >>> void CPSMDlg::OnOnCommMscomm1 ... >> // causes the OnComm event to NOT fire when a character is detected ... (microsoft.public.vc.mfc) - Re: without loop printing 1 to n
... int main ... void printrange ... from any other external name in the first six characters. ... underscore after the fifth character of this function name, ... (comp.lang.c) |
|