hello all, this is my first program in C++
its supposed to find the distance between two coordinates in the form (x,y)
when i substring the 'y' value, it keeps the ')' with it
heres the code... any help would be appreciated
Second of all, you need to #include <cstdlib> in order to use system().
(or, better yet, don't use system() - there are better alternatives)
Now, about your problem: num = input.substr(mid,end);
doesn't give you the substring between positions "mid" and "end".
It gives you the substring starting from position "mid" and with a length of "end" characters, or just from "mid" to the end of the string if there aren't "end" characters between "mid" and the end of the string.
(the reason it worked the first time, was that you probably just got lucky and the numbers happened to have worked out and given you the correct substring)
ahhh okay i see now. the substring in java is different than this. but why do i have to use int main() if im not returning anything? i was planning on just using cout for everything.
and how would you suggest going about this program?
The C++ Standard demands that main() return an int.
See, look!
my compiler wrote:
error: '::main' must return 'int'
(good news for you: it also says you don't have to put a return statement at the end of main()...it'll just be the same as if you had written return 0; at the end)
Here's a hint on the second parameter of substr: To get the number of integers from A to B, it's (B - A + 1).
(for example: number of integers from 6 to 17 = 17 - 6 + 1 = 12)