Dynamic function name in c

Status
Not open for further replies.

varunme

Advanced Member level 3
Joined
Aug 10, 2011
Messages
741
Helped
17
Reputation
36
Reaction score
17
Trophy points
1,318
Visit site
Activity points
5,765
Can we program like this, is there any otherway to achive this ?

Code:
int u;
void dext[1] ()
{        
         UART1_Write_Text("One");              // send text string to UART
}

void dext[2] ()
{        
         UART1_Write_Text("Two");              // send text string to UART
}

void dext[3] ()
{         
         UART1_Write_Text("Three");              // send text string to UART
}


void main()
{
        for(u=1;u<=10;u++)
             {
                 dext[u] ();

             }

}

The strings "ONE", "TWO", "THREE" are just examples here , i want to send dynamic text calculated from a loop
i want to know an alternative of switch case, as i think it will reduce the size of the program
 
Last edited:

Hello

code
 
Last edited:
Reactions: varunme

    varunme

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…