When I run my program i get weird things, my file reads correctly I just need help with the substring so the file outputs correctly. I just need help
this is what the file contains
A Samuel Spade Fido
A John Jones Rover
A Betsy Ann Smithville Jenny
H
H
A Lou Ann deVille Kitty
H
A Tom Smythe Fifi
A Marie Longfellow Jack
H
H
H
String parsing is fun, basically it goes as follow.
parsed = str.substr(int i, int j)
Where str is the whole string, and parsed is the section of the string you want.
int i is the start position, and int j is how long you want to parse.
So if you had the str = "balloon";
and you had parsed = str.substr(0, 4);
parsed would be the section of "ball"
You can combine this with delimiters to help parse out a string. For example, if you have a string "abcdefghijk" and want to stop at 'e' use
int found = str.find('e') and it will return the position of 'e' which would be 4. Then entering in str.substr(0,found) would get "abcd"
here is my output
Added: Samuel Spade Fido
Added: John Jones Rover
Added: Betsy Ann Smithville Jenny
Treated: Samuel Spade Fido
Treated: John Jones Rover
Added: Lou Ann deVille Kitty
Treated: Lou Ann deVille Kitty
Added: Tom Smythe Fifi
Added: Marie Longfellow Jack
Treated: Marie Longfellow Jack
Treated: Betsy Ann Smithville Jenny
Treated: Tom Smythe Fifi