User:Mirjam Dissel/clappingmusic in c
< User:Mirjam Dissel
Revision as of 19:42, 2 November 2010 by Mirjam Dissel (talk | contribs) (Created page with "This is still a work in process, but I decided to post it anyways. I used the 'while (repeat <12)' at first and then changed the whole code. Now I'm figuring out why adding/takin...")
This is still a work in process, but I decided to post it anyways. I used the 'while (repeat <12)' at first and then changed the whole code. Now I'm figuring out why adding/taking away this 'repeat' part doesn't make any difference to the pattern outcome.
Ok, so this is the clappingmusic.c file, made in gedit:
#include "stdio.h"
#include "string.h"
int shift = 0;
int i = 0;
int i2 = 0;
char *pat = "xxx xx x xx ";
int patlen = 0;
int repeat = 0;
int main (){
patlen = strlen(pat);
/*next line seems to do nothing, use debugger!*/
while (repeat < 12){
while (shift < patlen){
i = 0;
printf("--------------------------%d\n", shift+1);
while (i < patlen){
i2 = i+shift;
if (i2 >= 12){i2 = i2-12;}
printf("%c %c\n", pat[i], pat[i2]);
i++;
}
shift++;
}
/*next line seems to do nothing, use debugger!*/
repeat++;
}
}
compile it in terminal with:
gcc -g clappingmusic.c -o clappingmusic
If you need to debug at this point, use:
ddd clappingmusic
Then execute via:
./clappingmusic
ktnxbai