Hello! Well, I definde c_dest_entry as struct in a header-file (typedef struct ...). I believe that that's fine...
what you are telling me is, that calling printf with an actual copy of the tables line item, i.e. the whole struct is a problem (for printf, the compiler, who/whatever). Therefore using pointers (since pointer involve less computation) is probabely the solution - and more efficient anyways. Right? Now, I tried using pointers, actually that's where I started, but I somehow couldn't figure out how to do it... The compiler always complained, when I tried to access a field of the structure. Any suggestions on this? I'll try again tomorrow and maybe I'll have some more questions then. Thank you for your help, Tobias Zitat von Michael Schippling <[email protected]>: > What is a "c_dest_entry" and where do you initialize your array thereof? > > It would appear that c_dest_entry is a structure and thus so is "checking", > so when you go to printf checking (which is a copy of the current > int_table[i] entry) as an int the compiler is legitimately worried > about your intent... If you are working with an array of structs -- > rather then an array of simple ints -- you should probably use > pointers. See http://en.wikibooks.org/wiki/C_Programming for a good > intro to C if you don't know what I'm talking about. > > The runtime problem could be the result of not having your int_table > array fully initialized. Do you know for sure that there are 64 > (which is I assume the value of C_DEST_CID) valid elements therein? > > MS > > > [email protected] wrote: >> Hello, >> >> I'm trying to search an array of structs that I built to match some >> number. However when simulating my search-loop seems to be aborted >> somehow (always at the same index). >> >> I used the following Code: >> >> bool isin_cdest_table(c_dest_entry int_table[], uint16_t dest) { >> int i = 0; >> c_dest_entry checking = int_table[i]; >> while (((checking.t_dest) != dest) && (i < C_DEST_CID)) { >> i++; >> checking = int_table[i]; >> * printf("i: %hhu - checking: %hhu \n", i, checking); printfflush(); >> } >> printf("ENDE i: %u \n", i); printfflush(); >> if (i == (C_DEST_CID - 1)) { >> printf("NO C_DEST entry found \n"); printfflush(); >> return FALSE; >> } >> else { >> entry_found_no = i; >> printf("C_DEST entry found %hhu \n", i); printfflush(); >> return TRUE; >> } >> } >> >> This function is called in CC2420ActiveMessageP.nc inside the >> command AMSend.send. >> My Array has a size of 64 and the loop aborts at 12 (always). Can >> anyone help me? >> >> The compiler gives me the following warning I can't interpret: >> >> int format, c_dest_entry arg (arg 3) and refers to the line marked >> with an asterisk (*) >> >> Can anyone tell me: >> -WHY this is happening >> -HOW I can avoid it / fix it >> >> Thank you for your help. >> >> >> _______________________________________________ >> Tinyos-help mailing list >> [email protected] >> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
