Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
number analysis algorithm

Posted by nano (nano), 7 July 2006
Hi guys ,

Trying to write  some c code to do some number analysis  for example with ph. nos trying to manipulate if the  number is from it's home country or if its a free phone number oran international number ..

Any ideas how one might implement this through C ?

-your help is appreciated

nano

Posted by admin (Graham Ellis), 9 July 2006
I've done something just like this, though my language of choice at the time was Perl rather than C. I note you've previously posted to the Perl boards .. and I do think that would be a much better choice for you, although I don't know whether this request comes as part of a bigger project where there's good reason to use C?

In C, as in any language, I would start off by normalising my user's input - stripping out spaces, replacing initial string convernions such as "+" and "(0)" with what they mean when dialled locally.  

Second stage ... a match against a file of possible start sequences such as the one we have in our data library - see stdcodes.xyz -  using the C regular expression library.

Posted by nano (nano), 10 July 2006
Thanks for that - I will be writing in C++  as it's part of a proj.   Firstly i guess I will read table which defines all the countrycodes / area codes into a series of hash tables where the hashkey will be the CountrycodeAreaCode combined.

Have you done similar to this ?

thanks again.
Nano

Posted by admin (Graham Ellis), 11 July 2006
I don't think that having keys of a hashtable is going to make it particularly searchable when you want to look for numbers starting with a certain sequence ... that's why I used regular expressions.   Yes, I have done similar, but my requirement was to find a practical solution to a need rather than as a project / learning exercise.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2010: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 344596 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho