Jump to content

Recommended Posts

Posted (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 by Phatline
Posted

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.

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...