I'm new to this forum and how to use the "insert code" tool, so I'd appreciate help on that as well. In the following code, I get the error "Floating exception (core dumped)" and am not sure where it is coming from. Any help would be appreciated. The function is supposed to scan a fraction, then print the fraction again along with its reduced form.
To use code format, copy your code to the text box, then use either of these methods:
* Put [code] before and [/code] after it.
* Select it, then click the "insert code" button to the right of the text box. It will do what I explained above automatically.
I'm glad someone actually asked how to do it instead of just copying the code anyway.
It looks to me like you reinvented the wheel a bit with that get_fraction() function. There's already a method for converting a C string to an integer: int atoi(char*)
strpbrk() would help you parse the fraction, but I think it'd be simpler if you just entered the numbers separately.
Line 45: (int) "/"
This is invalid. You must have meant this: '/'
Test output: Input fraction (num/dem): 12/3
0/51=0/0
No exception, but something tells me that 0/0 isn't quite right.