I want to print every 2 Seconds a random music note on the terminal, to practices on my ocarina. The set of the music notes is (A, B, C, D, E, F and G), that is the code i need help with ,since i am new to coding.
#include <stdio.h>
#include <unistd.h>
int main(){
char A, B, C, D, E, F, G;
char notes[7] = { A, B, C, D, E, F, G };
while (1) {
printf("%c\n", notes);
sleep(2);
}
}
I get this error when compiling.
warning:format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘char*’ [-Wformat=]
printf("%c\n", notes);
When i change the %c in printf to %s all i get in the terminal "@" every 2 Seconds, what am i doing wrong? for the other part of my question how to add the print random notes which code i need to add?