How to get substring of a string without using string function and loop in C

1 Answer

0 votes
#include <stdio.h> 

void _substr(char s[], int start, int end) 
{ 
    if (start <= end) { 
        printf("%c", s[start]); 
        _substr(s, start + 1, end); 
    } 
} 
 
int main(int argc, char **argv)
{ 
	char s[] = "c programming"; 
    
	_substr(s, 0, 5); 
	
	printf("\n");
     
    return 0; 
}   
 
 
/*
run:
 
c prog
 
*/

 



answered Jan 14, 2019 by avibootz

Related questions

1 answer 203 views
1 answer 194 views
2 answers 191 views
1 answer 147 views
1 answer 145 views
1 answer 176 views
...