fork download
  1. /*ONJ PROGRAMMING CLUB var6.00*/
  2. /*QUIZMASTER ID rzH*/
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7.  
  8. int main(void)
  9. {
  10. char *str[4][]={
  11. {"A-1","A-2","A-3"},
  12. {"B-1","B-2","B-3","B-4","B-5","B-6","B-7","B-8"},
  13. {"C-1","C-2","C-3","C-4","C-5"},
  14. {"D-1","D-2","D-3","D-4"}};
  15.  
  16. int i=0;
  17. int j=0;
  18. int k=0;
  19. int str_random[5];
  20. int r;
  21. int cnt;
  22.  
  23. srand((unsigned)time(NULL));
  24.  
  25. for( i=0 ; i<10 ; i++ )
  26. {
  27. cnt = j = 0;
  28.  
  29. while( cnt < 5 )
  30. {
  31. r = rand();
  32.  
  33. if( cnt == 2 )
  34. {
  35. j--;
  36. }
  37.  
  38. if( r > sizeof(str[j][0])/sizeof(str[j][0][0]) )
  39. {
  40. continue;
  41. }
  42.  
  43. str_random[cnt] = r;
  44. j++;
  45. cnt;
  46. }
  47.  
  48. printf("%s%sha%swo%s%s¥n",str[0][str_random[0]],str[1][str_random[1]],str[1][str_random[2]],str[2][str_random[3]],str[3][str_random[4]]};
  49. }
  50.  
  51. return 0;
  52. }
  53.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:10:11: error: array type has incomplete element type ‘char *[]’
     char *str[4][]={
           ^~~
prog.c:10:11: note: declaration of ‘str’ as multidimensional array must have bounds for all dimensions except the first
prog.c:45:13: warning: statement with no effect [-Wunused-value]
             cnt;
             ^~~
prog.c:48:145: error: expected ‘)’ before ‘}’ token
         printf("%s%sha%swo%s%s¥n",str[0][str_random[0]],str[1][str_random[1]],str[1][str_random[2]],str[2][str_random[3]],str[3][str_random[4]]};
                                                                                                                                                 ^
prog.c:48:145: error: expected ‘;’ before ‘}’ token
prog.c:19:9: warning: variable ‘str_random’ set but not used [-Wunused-but-set-variable]
     int str_random[5];
         ^~~~~~~~~~
prog.c:18:9: warning: unused variable ‘k’ [-Wunused-variable]
     int k=0;
         ^
prog.c:10:11: warning: unused variable ‘str’ [-Wunused-variable]
     char *str[4][]={
           ^~~
prog.c: At top level:
prog.c:51:4: error: expected identifier or ‘(’ before ‘return’
    return 0;
    ^~~~~~
prog.c:52:1: error: expected identifier or ‘(’ before ‘}’ token
 }
 ^
stdout
Standard output is empty