小编Diy*_*Roy的帖子

使用C语言的递归

当我编译这个程序时,我只得到第一个大写字母而不是其余的.

输入:

ABldjfdslkjfCK

我只得到'A'就是这样吗?

#include <stdio.h>
#include <string.h>
FILE *fp;

int main(void)
{   
    int size; 
    char input[100]; // array size of 100 

    if (fp = fopen("message.txt","r")) // file exists
    {
        fgets(input,100,fp);// scans the sentence. 
    }
    else 
    {
    printf("file not found");// if there is no such a file. 
    }    

    size=strlen(input);  
    recursive(size,input); 

    return 0;
}

int recursive(int size, char array[])
{
    static int index = 0; // static so when the function is called, the  value is kept

    if (index < size) …
Run Code Online (Sandbox Code Playgroud)

c recursion

1
推荐指数
1
解决办法
2407
查看次数

标签 统计

c ×1

recursion ×1