How would one convert a string datatype, such as
"123+456"
My goal is to be able to have a user input a string as an equation then have my program read the first set of numbers in the string, then the mathematical symbol, then the second set of numbers and store the information. it would then read the symbol and either multiply, divide, subtract, or add the two numbers, and throw an error if any other is used, most likely using switches to determine this.
And convert it to two ints
int a = 123;
int b = 456;
From what I've read, %l is the length specifier, while d is the type specifier. %ld is equivalent to signed long int. I do believe that using %l without d is not a valid specifier.
scanf takes user input then stores them as the mod indicated to the address of the variable (i.e, 123+456 would be stored as
r = 123, c = '+', l = 456.
Using a switch to determine what to do, if s is a valid operand, then it performs the operation on the two long numbers.
1 2 3 4 5
Initialize variables
Get input
If middle input is a valid operand (+, -, /, *) perform the operation
Display output
Wait for another input
Capture all of say "25/100" with the use only pressing enter after 100? The goal of this is to have the user only press enter once. Not having to enter '25' then '/' then '100' but just a one time entry by the user.