Sponsored Content
Full Discussion: C Recursion (explain)
Top Forums Programming C Recursion (explain) Post 302416416 by seede on Monday 26th of April 2010 11:26:21 AM
Old 04-26-2010
Hi Guys,

Alright, the line:
if(line_of_char[index])
should have some problems with other systems, but somehow works for me right now. But I don't mind this for now :) (Thanks)

I've changed the code and output the index:
+0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17-17-16-15-14-13-12-11-10-9-8-7-6-5-4-3-2-1-0

The first print statement is using the value of index as it gets incremented 1,2,3 ...
I understand this one clearly since it's clear to me what the code is doing as it never reaches the 2nd printf so it keeps on calling 1st printf.

The second printf (after the recursive call) statement is going "back in time" by popping values off the stack 10,9,8, .....

I am still tying out to understand how it prints the 17 down to 1 since I never did something (index--). I understand the stack is going back but can you maybe help me understand this? Or, should I just set my thinking that it will go back after the recursive call of the 1st printf? (I'll read more about stack later on, need to learn C bit by bit)

:D Thanks a lot!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

recursion

I'm using the UNIX csh and i wish to use recursion to nav my way up (or down as it is) a given folder. My little test script is called "r" and takes a folder as argv (or $1) #!/bin/tcsh -f set allFiles = `ls -A $argv` cd $argv while ($#allFiles) if (-d... (1 Reply)
Discussion started by: gsjf
1 Replies

2. Shell Programming and Scripting

recursion too deep

I am running a korn shell script which has a recursive function. The script ran for 117 iterations and ended up with the following error "recursion too deep". what should be done to avert this? Thanks in advance Swamy p.s. I am on UNIX MPRAS V4 (3 Replies)
Discussion started by: swamy455
3 Replies

3. Shell Programming and Scripting

Problem with recursion in subdirectories

Hello ! I need some help with my simple bash script. This script removes all files ( with name given in $1 ) in current dir and subdirectories . The problem is with first loop in the script ( for file in * ; do ) . When I run the sript in my home directory this script display sometimes( ... (5 Replies)
Discussion started by: scotty_123
5 Replies

4. Shell Programming and Scripting

Help Help Help in recursion

Hello every body. I am trying to find the factorial using the following code. But it is giving the syntax error. I tried very much but in vain. Thanks in advance for helping me factorial() { if then y=`expr $1 - 1` x=$(( $1 \* factorial $y ))... (6 Replies)
Discussion started by: murtaza
6 Replies

5. Shell Programming and Scripting

diffrence in non recusion and recursion

Hi, If i have given to write a prog for factorial in C using recursion and without recursion which one is better in what condition and why ? thanks (2 Replies)
Discussion started by: useless79
2 Replies

6. Shell Programming and Scripting

How to remove old files without recursion?

Hi folks, I need to write a script which remove files with suffix *.dmp from a specific directory ,older than 30 days and not including recursive subdirectories. I.e: The following command remove recursive all *.dmp files older than 30 days: find $ORACLE_BASE -mtime +30 -type f -name... (5 Replies)
Discussion started by: nir_s
5 Replies

7. Shell Programming and Scripting

KSH: recursion into subdirectories?

Hello, I'm scripting a newbie. I'm using KSH on HP-UX. I'm trying to write a script that will change a whole directory of file names into UPPER CASE. I have the "convert to upper case" part of it working fine: ls | while read filename; do typeset -u uppercase uppercase=${filename} ... (2 Replies)
Discussion started by: Wotan31
2 Replies

8. Programming

Recursion

I want to halt a tail recursive function after certain validation. I want to come out of entire recursion without unwinding phase. How can i achieve that . The coding is done in C language. (5 Replies)
Discussion started by: joshighanshyam
5 Replies

9. Shell Programming and Scripting

script recursion

Can someone please explain me why the following script calls it self recursively: #!/bin/bash echo Called $0 while this not: #!/bin/bash echo Called $($0) Thanks (6 Replies)
Discussion started by: superpointer
6 Replies

10. Solaris

BIND 9, disable recursion

Hi, I am trying to disable the recursion on DNS server (Solaris 10). I have added the lines in the named.conf as below: allow-query-cache { none; }; recursion no; Then restarted the solaris DNS services svcadm refresh svc:/network/dns/server:default Still I am able to... (0 Replies)
Discussion started by: snchaudhari2
0 Replies
GRUB-RENDER-LABEL(1)                                               User Commands                                              GRUB-RENDER-LABEL(1)

NAME
grub-render-label - generate a .disk_label for Apple Macs. SYNOPSIS
grub-render-label [OPTION...] [OPTIONS] DESCRIPTION
Render Apple .disk_label. -b, --bgcolor=COLOR use COLOR for background -c, --color=COLOR use COLOR for text -f, --font=FILE use FILE as font (PF2). -i, --input=FILE read text from FILE. -o, --output=FILE set output filename. Default is STDOUT -t, --text=STRING set the label to render -v, --verbose print verbose messages. -?, --help give this help list --usage give a short usage message -V, --version print program version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. REPORTING BUGS
Report bugs to <bug-grub@gnu.org>. SEE ALSO
The full documentation for grub-render-label is maintained as a Texinfo manual. If the info and grub-render-label programs are properly installed at your site, the command info grub-render-label should give you access to the complete manual. grub-render-label (GRUB) 2.02-2ubuntu8.3 July 2018 GRUB-RENDER-LABEL(1)
All times are GMT -4. The time now is 04:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy