アプリ版:「スタンプのみでお礼する」機能のリリースについて

abcdefghを反転させたいのですが、
?に入る式がわかりません。
#include <stdio.h>
#define N 8

void revstr(char s1[], char s2[], int n){
if (n < N){
char buf = s1[n];
revstr(s1, s2, n+1);
*(s2 + ? ) = buf;
}
}

int main(void){
char s1[N+1] = "abcdefgh", s2[N+1];
printf("%s\n", s1);
revstr(s1, s2, 0);
s2[N] = '\0';
printf("%s\n", s2);
return 0;
}

A 回答 (4件)

N-n-1



n=0のときは、s2[7]
n=1のときは、s2[6]

n=7のときは、s2[0]

となります
    • good
    • 0
    • good
    • 0

buf って変数はなんのためにあるの?

    • good
    • 0

関数の仕様はありますか?

    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!