I'm trying to create a program that takes in a number such as "12345678" or "12345678910" and formats them into "1-234-5678" or "1-(234)-567-8910" respectively. It shows no errors in the compiler but when I enter a number, I get the error message "expression string subscript out of range" and forced to abort.
Any ideas? Thank you so much in advanced.
Without code-tags it is next to impossible to read your program and discern what you're doing wrong. Based on the headline statement of your problem here's a std::regex based approach: I'm not sure how familiar you're with std::regex, therefore I'm not sending any detailed explain at this stage but if you're interested you can start with this link: http://www.cplusplus.com/reference/regex/ECMAScript/, google some more and then come back here if you have any queries:
This is all very confusing for me. Thank you gunnerfunner, I'll look into that. I'll try to use this more with my next program. Unfortunately, I have to sort of follow the pseudocode that's been given my instructor.
can you isolate what line this happens @ via the debugger?
Other than what's above I get this message following the debug:
'ConsoleApplication7.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
Along with several similar messages right below it.s
formatNumber is fed an empty string and you assume it was not.
Not helping the situation: isValid can only return a non-zero value since the condition on line 43 can never be false. Any value is either greater than seven or less than 12. Some values are both.
Also, on line 19 you do nothing with the value returned by enterPhoneNumber effectively ignoring whatever number the user gives you.