Click here to Skip to main content
16,006,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have defined some functions in a class that changes or print or read information from a linked list : add_book(int booknum) / print_book and so on ..
the user writes a command like :add 123
I want my program to split the string into :string"add" and int"123" and run the add_book(int booknum)(i.e: use "add" as a keyword to run the function add_book)

What I have tried:

at first I thought we can use argc,argv to solve the problem but argv is always considered as a string (char)
Posted
Updated 24-Oct-16 16:45pm
Comments
[no name] 24-Oct-16 16:15pm    
Are you working on the same homework assignment as http://www.codeproject.com/Questions/1147369/How-do-I-let-the-user-enter-two-commands-in-one-li?
Member.R 24-Oct-16 16:37pm    
Yes! I have the same problem but it seems he explained it better !
I still didn't get any useful help from the solutions there!

[no name] 24-Oct-16 17:51pm    
So what more is it that you think we should do for you? What did your teacher say when you asked for help?

1 solution

If the second argument of the command is expected to be an integer, you can use atoi[^] on it to convert a string to integer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900