Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C function to call 5 different functions

C function to call 5 different functions

Scheduled Pinned Locked Moved C / C++ / MFC
career
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12100921
    wrote on last edited by
    #1

    I've been recently asked in an interview to write down a function that takes a char and returns void, and using this char the function would call between 5 different functions, Beside I have to write this function in three different ways. I figured out two, but failed to come with the third. My two functions were : 1- using switch on the coming argument 2 - using if else statements ,, can some 1 deduce the third , this is bugging me.

    Richard Andrew x64R 1 Reply Last reply
    0
    • U User 12100921

      I've been recently asked in an interview to write down a function that takes a char and returns void, and using this char the function would call between 5 different functions, Beside I have to write this function in three different ways. I figured out two, but failed to come with the third. My two functions were : 1- using switch on the coming argument 2 - using if else statements ,, can some 1 deduce the third , this is bugging me.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Here's an idea: Use the char as an array index for an array of function pointers.

      The difficult we do right away... ...the impossible takes slightly longer.

      U 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        Here's an idea: Use the char as an array index for an array of function pointers.

        The difficult we do right away... ...the impossible takes slightly longer.

        U Offline
        U Offline
        User 12100921
        wrote on last edited by
        #3

        alright I like this one :thumbsup::thumbsup:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups