Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
#include<stdio.h>
void abc(char*s)
{

if(s[0]=='\0')
    return;
abc(s+1);
abc(s+1);
printf("%c",s[0]);
}
int main()
{
    abc("123");
}


What I have tried:

i have tried recursions for the execution of function abc(char *s).
Posted
Updated 23-Mar-17 8:35am
v2
Comments
[no name] 23-Mar-17 13:34pm    
Learn how to use the debugger to step through your code.

1 solution

Quote:
Why the output of the program is 3323321? What does return function does in function abc?

That is what you asked for.

When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 
Comments
Maciej Los 23-Mar-17 15:12pm    
Debugging a program is very good advice. +5
Patrice T 23-Mar-17 16:06pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900