[Dev-C++] need help on converting a phone number
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Alan T. <ala...@3n...> - 2001-01-27 20:13:15
|
Are you just in C or C++? strtok is a terrible function, because it destroys the original string by placing a NULL character at the location of the delimiter. So, if you use it, you should copy the original string into a temporary one. See http://www.gator.net/~garyg/C/FUNCTIONS/strtok.html for info on the function. If you can use C++, there are some nice string operations (find, substr, etc.) to do things like this easily. You could read it in as a string, find a delimiting character (or string or from a set of characters) and extract a substring, without messing up the original string. This is a much cleaner implementation. See http://www.icce.rug.nl/docs/cplusplus/cplusplus.html for a tutorial on these string operations -- find the string section. Alan |