Hi everyone, this is a small snippet of code from my school project:
Code:
#include <stdio.h>
int main(void) {
char menu[5][35] = {"Please select one of the following:", "A. Define Random Number List", "B. Sort Number List (High to Low)", "C. Sort Number List (Low to High)", "D. Exit"};
for (size_t i = 0; puts(menu[i]), i < 4; i++);
return 0;
}
When I run it, element 1 ("A. Define Random Number List") is printed twice. No matter what I try, element 1 is always duplicated.
Why is this happening?
EDIT: Fixed it, still not sure why that happened though. I wrote *menu[5] instead of menu[5][35] and that worked.