Im trying to write a program that will scan both characters and numbers from a user then put the number into an array or call another function based on the user input.

For example the user will type 'Insert 3' and this will call the function to put 3 into an array. my problem is im not sure how to read the letters as letters and evaluate them so i know which function to call and at the same time read the number as a number and put it into an array.

Im not sure how clearly im explaining things but im stuck and i have absolutely no idea how to start this. I haven't written any code for this part as yet cause i don't know how to solve the problem in my head so i don't know what i should be coding. If someone can point me in the right direction i would really appreciate it.

You might need to expand on what the user input options are and what needs to be done in different circumstances. You give "insert 3", but it sounds like there are other options as well. what are some of the other options?

Compare the beginning of the string with each of the 'commands' and when you get a match test the rest of the string for the parameter(s), converting the digits to numbers if needed.

You might need to expand on what the user input options are and what needs to be done in different circumstances. You give "insert 3", but it sounds like there are other options as well. what are some of the other options?

There are 3 options: Insert x (x has to be a number)
Find-Min
Extract-Min

Only the insert option has this format, the other two are more straight forward.

Insert x allows you to put the number into an array and use heap sort to sort it.
Find-Min lets you display the minimum value in the array.
Extract-Min removes the minimum value from the array while maintaining the heap order.

What WaltP said...

Read the command. Compare it to the three valid commands. if not one of the three, it's invalid. If it's not "insert", you should be done. Read in the rest of the line. If there's anything but white space in the rest of the line, it's an error unsless the command was "insert".

If it was "insert", read in the next parameter as a string, then use sscanf or strtol or strtod to convert that string to a number, and go from there with the "insert" command.

Ok i get it now. Thanks you guys!! Really saved my butt lol

This question has already been answered. Start a new discussion instead.