Witam
Zadanie z codewars
https://www.codewars.com/kata/62eb800ba29959001c07dfee/train/c
Kod żródłowy poniżej
#include <stdlib.h>
char *brightest_color (char *brightest, char const *const colors[])
{
// colors[] is NULL-terminated
// write to brightest and return it
char R[5]="0x\0";
char G[5]="0x\0";
char B[5]="0x\0";
int r;
int g;
int b;
int Vmax=0;
int maxVmax=0;
//brightest=(char*)malloc(sizeof(char)*8);
int index=0;
for(int i=0;colors[i]!=NULL;i++)
{
strncat(R,colors[i]+1,2);
strncat(G,colors[i]+3,2);
strncat(B,colors[i]+5,2);
r=strtoul(R,NULL,16);
g=strtoul(G,NULL,16);
b=strtoul(G,NULL,16);
Vmax=fmax(r,fmax(g,b));
printf("%d\n",Vmax);
if(Vmax>=maxVmax){
strcpy(brightest,colors[i]);
printf("%s\n",brightest);
maxVmax=Vmax;
index=i;
}
//printf("%s\n",brightest);
}
return brightest;
}
I zwraca mi błąd "you must return the given string".
Proszę o pomoc powie ktoś w którym miejscu jest błąd.