Recursive problem
From: Andy (anaylor_at_nc.rr.com)
Date: 01/25/04
- Next message: entropy123: "Re: [C++] Best Way to ++booleans?"
- Previous message: Robert W Hand: "Re: <windows.h> using ANSI C++"
- Next in thread: James Connell: "Re: Recursive problem"
- Reply: James Connell: "Re: Recursive problem"
- Reply: Jack Klein: "Re: Recursive problem"
- Reply: James Connell: "Re: Recursive problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Jan 2004 09:25:36 -0800
Working on Recursion in a CSC class.
The object is to create a recursive string length function w/o using
strlen.
I'm having problems with my code causing a segmentation fault. It
looks as if it's not returning 0 in the base case.
Function Code:
int recursivestringlength(const char buffer[]){
if (buffer=='\0')
return 0;
else
return(1+recursivestringlength(buffer+1));
Function Call:
const char s[80]="";
int job = recursivestringlength(&s[1]);
Any ideas?
Thanks,
Andy...
- Next message: entropy123: "Re: [C++] Best Way to ++booleans?"
- Previous message: Robert W Hand: "Re: <windows.h> using ANSI C++"
- Next in thread: James Connell: "Re: Recursive problem"
- Reply: James Connell: "Re: Recursive problem"
- Reply: Jack Klein: "Re: Recursive problem"
- Reply: James Connell: "Re: Recursive problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|