Submission #307495

#TimeUsernameProblemLanguageResultExecution timeMemory
307495giorgigagua2006Exercise Deadlines (CCO20_day1problem2)C11
Compilation error
0 ms0 KiB
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #define task_count 10 int main() { uint8_t swap = 0; uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9}; uint8_t * cpy_tasks; uint8_t deadline[] = {2,3,7,1,5,4,9,0,6,8}; memcpy(cpy_tasks, tasks, 10); uint8_t temp; for (size_t i = 0; i < task_count; i++) { temp = tasks[i]; if(tasks[i] != cpy_tasks[deadline[i]]) { tasks[i] = cpy_tasks[deadline[i]]; swap+=task[i]; } tasks[deadline[i]] = temp; } return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:12:22: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                      ^
Main.c:12:22: note: (near initialization for 'tasks')
Main.c:12:24: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                        ^
Main.c:12:24: note: (near initialization for 'tasks')
Main.c:12:26: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                          ^
Main.c:12:26: note: (near initialization for 'tasks')
Main.c:12:28: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                            ^
Main.c:12:28: note: (near initialization for 'tasks')
Main.c:12:30: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                              ^
Main.c:12:30: note: (near initialization for 'tasks')
Main.c:12:32: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                ^
Main.c:12:32: note: (near initialization for 'tasks')
Main.c:12:34: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                  ^
Main.c:12:34: note: (near initialization for 'tasks')
Main.c:12:36: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                    ^
Main.c:12:36: note: (near initialization for 'tasks')
Main.c:12:38: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                      ^
Main.c:12:38: note: (near initialization for 'tasks')
Main.c:24:11: error: 'task' undeclared (first use in this function); did you mean 'tasks'?
   24 |     swap+=task[i];
      |           ^~~~
      |           tasks
Main.c:24:11: note: each undeclared identifier is reported only once for each function it appears in
Main.c:11:9: warning: variable 'swap' set but not used [-Wunused-but-set-variable]
   11 | uint8_t swap = 0;
      |         ^~~~