Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Menu Driven String Editor

  1. Sep 30, 2006 #1
    I'm having some trouble writing the menu part of this program. Right now, I have everything in main() just for ease of compiling. The file is attached.

    There are 5 basic commands: I, D, L, A, E
    I = insert a line, D = Delete a line, L = list a line, A = Append to end of list,
    E = exit.
    Thats easy. The hard part is that a line number may follow the command.
    I 5 means insert a string that follows before line 5.
    D 5-13 means delete lines 5 through 13.
    L 3 - 7 means list lines 3 - 7.

    If text follows the numbers then it is considered a string and not a command.

    I bring in the line using cin.getline(newString, 255, \n). newString is of type char. I'm not sure what to do with the loop to determine if there are numbers, then if the line is more than one digit ( 20 ) how do I push them together to represent the line number, AND then if there is letters after the numbers its a string... its all so confusing!

    Please help me get through this!!! :eek:

    thank you so much for your help!


    Attached Files:

  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?