Click here to Skip to main content
15,914,395 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Compile with version.lib Pin
vcplusplus31-Oct-04 16:18
vcplusplus31-Oct-04 16:18 
GeneralRe: Compile with version.lib Pin
Steve S31-Oct-04 22:44
Steve S31-Oct-04 22:44 
GeneralDownloader and Install files from the WEB (Like the Windows Updates) Pin
programming31-Oct-04 12:04
programming31-Oct-04 12:04 
GeneralRe: Downloader and Install files from the WEB (Like the Windows Updates) Pin
KRowe31-Oct-04 22:29
KRowe31-Oct-04 22:29 
GeneralLoading a Resource into a Stream Pin
Member 21854431-Oct-04 12:04
Member 21854431-Oct-04 12:04 
GeneralRe: Loading a Resource into a Stream Pin
Michael Dunn31-Oct-04 18:30
sitebuilderMichael Dunn31-Oct-04 18:30 
GeneralLookup (Dispatch) Table Pin
Member 569752131-Oct-04 11:59
Member 569752131-Oct-04 11:59 
GeneralRe: Lookup (Dispatch) Table Pin
Ryan Binns31-Oct-04 17:51
Ryan Binns31-Oct-04 17:51 
Your best bet would be to use function pointers in a lookup table. Assuming all the functions return void and take no parameters...
void (*functions[])() = { cmd0, cmd1, cmd2, cmd3 }; // cmd0 etc. are the function names
...
char string[3] = "48";     // The 2-character string you read from the serial port
int number = atoi(string); // Convert to an integer
if (number >= 0 && number <= 3) // sanity check
{
  (*functions[number])();
}
Just make sure that you never index your array out of bounds, or you'll have huge problems, and the errors probably won't make any sense. The first element in the array will be if a 0 is received, the second element for a 1 received etc.

Hope this helps

PS. Look up a textbook on function pointers if you're not sure how they work.

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralHide logical disk compeletely Pin
faroqtam31-Oct-04 10:31
faroqtam31-Oct-04 10:31 
GeneralRe: Hide logical disk compeletely Pin
David Crow1-Nov-04 6:21
David Crow1-Nov-04 6:21 
GeneralSome help of how i can send files remotely in network. Pin
faroqtam31-Oct-04 10:09
faroqtam31-Oct-04 10:09 
GeneralRe: Some help of how i can send files remotely in network. Pin
KRowe31-Oct-04 21:03
KRowe31-Oct-04 21:03 
GeneralConnection to MS Access Database Pin
WinAPILearner31-Oct-04 8:08
WinAPILearner31-Oct-04 8:08 
GeneralRe: Connection to MS Access Database Pin
David Crow1-Nov-04 6:27
David Crow1-Nov-04 6:27 
GeneralRe: Connection to MS Access Database Pin
WinAPILearner1-Nov-04 21:34
WinAPILearner1-Nov-04 21:34 
GeneralRe: Connection to MS Access Database Pin
David Crow2-Nov-04 2:30
David Crow2-Nov-04 2:30 
GeneralRe: Connection to MS Access Database Pin
David Crow2-Nov-04 7:48
David Crow2-Nov-04 7:48 
GeneralRe: Connection to MS Access Database Pin
David Crow2-Nov-04 8:04
David Crow2-Nov-04 8:04 
GeneralRe: Connection to MS Access Database Pin
WinAPILearner2-Nov-04 10:09
WinAPILearner2-Nov-04 10:09 
GeneralRe: Connection to MS Access Database Pin
David Crow2-Nov-04 10:24
David Crow2-Nov-04 10:24 
GeneralRe: Connection to MS Access Database Pin
WinAPILearner2-Nov-04 20:12
WinAPILearner2-Nov-04 20:12 
GeneralRe: Connection to MS Access Database Pin
David Crow3-Nov-04 2:31
David Crow3-Nov-04 2:31 
GeneralRe: Connection to MS Access Database Pin
WinAPILearner3-Nov-04 7:42
WinAPILearner3-Nov-04 7:42 
GeneralRe: Connection to MS Access Database Pin
David Crow3-Nov-04 9:41
David Crow3-Nov-04 9:41 
GeneralConsole Threading Problem Pin
Joe_Sextus31-Oct-04 7:36
Joe_Sextus31-Oct-04 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.