c - Debugging program with pointers and arrays -


kindly in resolving this,the error i'm getting here syntax near '{' since had declared unsigned char near dac_table got error,so define outside function wrong...i have not posted complete code here...in part of code i'm getting problem..

unsigned char dac_table[16];      unsigned char *ptr2tbl;  void fnselectvoltage(void) {     line_display(1, "volt sel");     sprintf(line_buf," %d v",(unsigned int)*ptr2tbl);            line_display(2, line_buf);      dac_table[16] = ( 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);     *ptr2tbl = &dac_table;       while (start_key)     {         if (!up_key)         {                wait_for_any_key_counter_0 = 0;             (i = 0; i<15; i++)                   {                 p2 = *ptr2tbl++;                             //  delay_ms(1000);                      }         }         else if(!down_key)         {             wait_for_any_key_counter_0 = 0;             (i = 0; i<15; i++)                   {                 p2 = *ptr2tbl++;                                 // delay_ms(1000);                           }         }     } } 

unsigned char dac_table[16];// u hv created global array here  

to assign values it,

    dac_table[0] = 0x00;     dac_table[1] = 0x01; , on. 

or better

unsigned char dac_table[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; @ line of declaration. 

you can't assign values variables @ file scope except @ line of declaration.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -