Phatline Posted July 7, 2014 Report Share Posted July 7, 2014 (edited) I am new in C, but my code works, but to big to slow, time to use matrices and ARRAYS I declare and initalise a array: #include <mios32.h> #include "app.h" //1st NoteArray/Buffer u8 NteBuf0[10]={0} u8 NoteCount later I want to write a 0 in all Cells of the Array, e.g: void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package) //CLEAR NOTE BUFFERS (set to Note Nr 0, which we filter later out) if(port == 33 && midi_package.type == NoteOff && midi_package.chn == Chn8 && NoteCount == 0){NteBuf0[10] = { 0 };} "make" give me e.g. "expected expression before '{' token" also tried: {NteBuf0[] = 0;} {NteBuf0[] = { 0 };} {NteBuf0[10] = { {} };} memset(NteBuf0, 0, 10) {NteBuf0[10] = 0;} make: "warning: array subscript is above array bounds [-Warray-bounds]" and a view others that i dont remember (because of not working in this case) writing them one by on by one.... works of course What do i missed to know? Edited July 7, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
TK. Posted July 7, 2014 Report Share Posted July 7, 2014 There are so many helpful C courses available in the internet... did you ever google for "C kurs"? E.g. I entered "C kurs arrays", and this was the first hit: http://www.peace-software.de/ckurs8.html However, if you want to write a value into all items of an array, write: { int i; for(i=0; i<10; ++i) NteBuf0 = 0; } Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Phatline Posted July 7, 2014 Author Report Share Posted July 7, 2014 thx for looking in > code works at google - quick shot, foul etc mentality: i even slept a night over it, printed some array courses to A3-Pack at work, searching google on this todays eveining and so on: i crossed a lession about how to initalze a 2D array... yes at this point only at declaration... http://stackoverflow.com/questions/1688741/initialize-a-2d-array-at-declarationtime-in-the-c-programming-language but here: http://stackoverflow.com/questions/4066522/setting-an-array-to-one-value - so I the idea there is some nice "Reset" or "Blank" function behind Array, but that dont work so my thougt was that there are differences by this uC-C? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.