User Profile
Collapse
-
Banfa, you're right, my input string was a pointer to something that didn't exist past the function that generated it. (Grr, dumb error that took hours to debug and two seconds to fix.) Thanks for all your help! I much appreciate your looking at my code and helping me fix/debug it. -
Thanks, Banfa! I fixed the error you pointed out on line 14.
Meanwhile, I'm sorry to report that the code still isn't working for me at all. As I step through the code line by line, the debugger shows that if validNum is (123)456-7890, then as the function executes, on line 10 validNum changes to (123)456-7. On line 11, it changes to (123)45, and so on. Ultimately what gets returned is a string with just the second char "1"....Leave a comment:
-
Strings in C
Hello. I'm new to C, and trying to figure out why some code I wrote isn't working. The code is supposed to receive a telephone number that could be formatted with digits, parenths, or dashes. It is supposed to strip out the parenths and dashes, retaining just the digits. Here's the code:
Code:char* formatNum (char* validNum) { int counter; int index; int length; char* numOut;
No activity results to display
Show More
Leave a comment: