GetSubstring関数を使用して結果を出力し、次のようにする必要があります。
printf(GetSubstring("character", 4, 3, resultArray));
出力act
制限事項:他の関数またはマクロを呼び出すことはできません。他の変数を追加することはできません。変数を0に設定することはできません。関数GetSubstringのみを変更できます。
これが私の現在のコードです。
#include <stdio.h>
#include <stdlib.h>
char *GetSubstring(const char source[], int start, int count, char result[]);
int main(void)
{
const char source[] = "one two three";
char result[] = "123456789012345678";
puts(GetSubstring("character", 4, 3, result));
return(EXIT_SUCCESS);
}
char *GetSubstring(const char source[], int start, int count, char result[])
{
char *copy = result;
for (; *source != '\0' || *source == source[start]; start--)
{
while (*source != '\0')
{
*result++ = *source++;
}
}
*result = '\0';
return (copy); // outputs character
// return (result); // outputs 012345678
}
ご協力ありがとうございました。