Assignment for class?
If you just want to accept "y = ax + b" and not any formula, it's pretty simple.
1. read the whole line into a string
2. split the string into sub-strings for the proper parts (can throw away all except a and b)
3. use atof() on the a, b parts.
2. is of course the hard part, you must know how to traverse a string character-by-character and how to create a string from part of another string.
Hopefully no one will post a working program, so you can learn on your own.