Thread: Creating Interactive Application (Novice Question)

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    2

    Question Creating Interactive Application (Novice Question)

    Hello,

    I just recently decided to dive into the world of C Programming and I cannot think of a better way to provide myself with more experience by writing longer applications with multiple functions than just "Hello World!"

    (I am sorry as I do not know the technical jargon yet so I will try and explain my goal as much as possible and hope it is understood)

    I want to write a simple application which will preform different action based on different input. For example I would want say 5 options, 5 different keys to choose from, say 1 - 5. How would I give different functions to different keys? So if someone choose "1" that it would preform actions from "1" and not say "2". So I am trying to have different actions or maybe even multiple actions or functions linked through a pathway which have different end results -- as in say clicking "1" could take you to a whole new set of actions to choose from that "2" would never take you too.

    Now it would take all the fun out of trying to create the application if someone did it for me, I just need help figuring out how to link functions and actions to different functions and actions -- and possibly a way for the application to recognize if imputed characters are valid or invalid (so if someone theoretically typed in "6" it would bounce back and say invalid selection).

    So nothing too complicated, but my goal is to create an app with limited interactivity between the user and program; I think this will be the best way to experiment with the powers of Programming.
    Last edited by Nick Colby; 12-22-2012 at 06:54 PM. Reason: Improved Read-ability

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I'm a little unclear on exactly what you're asking.

    Assuming you've done the "hello world" example, you know that the journey of C/C++ programming pretty much starts out with basic console [text] programs. In this case, making simple menu driven programs can be achieved early on in the learning process. It's a simple combination of reading user input, and applying basic logic to determine which code to execute. After you get your feet wet with basic I/O, conditional statements, and loops, you can easily code a program that meets the requirements you describe.

    It's also possible you mean that pressing a certain key will make your OS perform a certain action (i.e. run another program, copy a file, etc). This, too, is possible, but more advanced.

    Learning on your own is always best done with the help of a good introduction to programming book. After reading the material, trying out the example code, and doing any exercises provided, you will get a better sense of how to program, as well as what you'll eventually be able to achieve with programming.

    Does any of this help answer your questions?

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    2
    Quote Originally Posted by Matticus View Post
    I'm a little unclear on exactly what you're asking.

    Assuming you've done the "hello world" example, you know that the journey of C/C++ programming pretty much starts out with basic console [text] programs. In this case, making simple menu driven programs can be achieved early on in the learning process. It's a simple combination of reading user input, and applying basic logic to determine which code to execute. After you get your feet wet with basic I/O, conditional statements, and loops, you can easily code a program that meets the requirements you describe.

    It's also possible you mean that pressing a certain key will make your OS perform a certain action (i.e. run another program, copy a file, etc). This, too, is possible, but more advanced.

    Learning on your own is always best done with the help of a good introduction to programming book. After reading the material, trying out the example code, and doing any exercises provided, you will get a better sense of how to program, as well as what you'll eventually be able to achieve with programming.

    Does any of this help answer your questions?
    Actually yes it does, thank you. I guess everything I need to learn to accomplish this application is in the field of I/O. You mention that C/C++ starts out with basic console output, but is it always going to be based in the console? Would I use C to create GUI interfaces or have I missed the purpose of The C Language?

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    You can use C/C++ to create GUIs, though this would be a more advanced level of programming.

    The reason C/C++ learning usually starts in the console is because the console is relatively simple, and interacting with it does not require much code on the programmers part. This makes it a good introduction and a natural lead-in to more sophisticated programs.

    Once you are familiar with the rules and syntax of the language, you can use these coding skills in conjunction with pre-existing libraries to create, well, all sorts of programs.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by Nick Colby View Post
    I want to write a simple application which will preform different action based on different input. For example I would want say 5 options, 5 different keys to choose from, say 1 - 5. How would I give different functions to different keys? So if someone choose "1" that it would preform actions from "1" and not say "2".
    It sounds like you want a multi-way decision. In C the normal way is either a switch statement or an if ... else if ... else if ... else sequence. One simple example: suppose you have read the code you described as a digit '1'...'3' and you have already defined three functions action_one, action_two, action_three. Then you could run something like this in a loop:

    Code:
    switch(code) {
       case '1': 
          action_one();
          break;
       case '2': 
          action_two();
          break;
       case '3': 
         action_three();
         break;
       default:
         printf("Unknown code\n");
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another Novice question..
    By Paradigm in forum C Programming
    Replies: 4
    Last Post: 03-12-2011, 10:33 AM
  2. Interactive vs non-interactive terminal session question
    By Overworked_PhD in forum Tech Board
    Replies: 2
    Last Post: 06-18-2009, 07:30 PM
  3. Replies: 10
    Last Post: 06-17-2005, 10:00 PM
  4. Novice question.. please help.
    By sivex in forum C Programming
    Replies: 1
    Last Post: 03-15-2005, 11:26 AM
  5. C or C++ the Eternal Question or Perhaps Not for a NOVICE
    By bobbyjrbbobbyjr in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-23-2002, 09:23 PM