Wednesday, December 21, 2011

domain name and website name

domain name is like : wengjn.com
website name is like: www.wengjn.com

you buy a domain name is like you buy a land, where you can build anything you want: home.wengjn.com
or people.wengjn.com

a few popular hosting company
http://www.headfirstlabs.com/providers.html

domain name reg
http://www.internic.net/regist.html

URL: uniform resource locator

when the browser is asking for a directory/folder instead of a file???
if it ask for www.starbuzz.com
first it will automaticly change it into www.starbuzz.com/ which is the root folder for your website
and then it will go to its default file: index.html or default.htm (but you may need to find out what your hosting company really default)

Saturday, December 17, 2011

write your own: atoi()

atoi() function: converse a string into an integer
int atoi ( const char * str );
This is how it did:
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus orminus sign followed by as many numerical digits as possible, and interprets them as a numerical value.

The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.

If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
We only need to consider to convert "19" into 19. No need to consider whitespace



int myatoi(const char *str)
{
int i = 0;
while(*str)
{
i = i << 3 + i << 1 + (*str - '0');
str++;
}
return 0;
}