Needing help making my first program

Hi all :)

I'm an absolute beginner (started yesterday, using wxDev-C++) and am trying to make a very basic console program that once launched shows:

[a] Display messages
[b] Go to message
[c] Help


Once [a] is selected the screen will clear and display message #1 of 50, at that point:
D = clear screen and show the next message
A = clear screen and rewind back one message
X = exit to main screen

Once [b] is selected it'll read user input of ## and clear the screen and display that message, at that point:
S = search again
X = exit to main screen


A couple of questions:
1) What's the best practice to store each one of the 50 messages and identify them so they can be called for use in [a] and [b]?
2) For [a] How do I read character and advance to next message without the need to press enter after reading an input? So far I've managed to read keystroke and go to another program but they require hitting [enter] afterwards.


Thanks in advance for any assistance, much appreciated!

Save all the messages in a double dimension array. In your case as you know it will be 50, so make an array like this:

1
2
3
4
#define MAX_MSG 50
#define MAX_LEN 1024

char Messages[MAX_MSG][MAX_LEN];   //this can strore 50 messages of max length 1024 


read each message with a scanf command. Run this in a while loop untill the user keeps on entering messages. As soon the user stops the loop will break.

Store a counter which will point to the current message in the Message array. when the user will press an 'a', print like this:

printf("%s", Message[counter]);

and than advance the counter by one for the next message to show.

Post your code which will help.
Topic archived. No new replies allowed.