dimanche 21 avril 2019

C : Does not print the array index in variadic functions

I want to print the index in the array with random. But I cant.

Main.c:

RastgeleKarakter randomB = overload5_specifiedRandom(6,'g','y','u','c','n','e');

RastgeleKarakter.c

RastgeleKarakter overload5_specifiedRandom(int args,...){
  va_list list;
  va_start(list, args);
  char array[7];
  char* test;
  int sayi = (int) ((Now())%args);
  for(int i = 1; i <= args; i++){
    array[args] = (char) va_arg(list,int);
    printf("%c ", array[args]);
  } 
  printf("%d",sayi);
  va_end(list);
}

Out:

g y u c n e 3╝

I want this out :

'u' or 'g' or 'c' 




Aucun commentaire:

Enregistrer un commentaire