How do I split a string
input into two different int
s?
I am writing a program to input two different fractions (like 2/3
) and am wanting to read in the 2/3
as a string and split it by a delimiter (the /
).
Example:
Input: 2/3
Values:
int num = 2;
int denom = 3;
Example 2:
Input: 11/5
Values:
int num = 11;
int denom = 5;
Thanks!