2017-01-31 14:36:53 +00:00
I think for long time, new C language programmer is getting rare.
As I'm solving the Eudyptula Challenge, an idea came to me that similar challenge is necessary for C language.
2018-06-11 21:02:12 +00:00
Usually book authors create some exercises carefully for each chapter in their books.
They hope that many readers solve the exercises and have got the alive wisdom.
You will get the dead kwowledge via reading text, but the alive wisdom via solving exercises and creating code.
Only some people solve the exercises and a few people solve the exercises correctly.
2017-02-23 11:53:15 +00:00
2018-06-11 21:02:12 +00:00
Here is a paradox.
If you are able to solve the exercises correctly, and have insight to the purpose of author, you are already having enough wisdom and do not need to read the book.
If you are not able to solve the exercises correctly, you are not able to get the wisdom via the book.
2018-06-11 20:36:21 +00:00
2018-06-11 21:02:12 +00:00
Here is a solution.
If somebody shows you a solution, you cannot realize Tao.
2018-06-11 22:08:57 +00:00
But if somebody review your solution and present the right direction, you will be able to realize Tao.
2018-06-11 21:02:12 +00:00
[Tao (The Way) that can be spoken of is not the Constant Tao’ ](https://en.wikipedia.org/wiki/Tao_Te_Ching )
2017-02-23 11:53:15 +00:00
2018-06-11 22:08:57 +00:00
[Do not satisfy with reading text. Start creating code. ](http://www.taoism.net/living/2007/200701.htm )
2018-06-11 21:02:12 +00:00
# exercises of "The C programming language: 2nd"
2018-06-11 20:39:31 +00:00
2018-06-11 21:02:12 +00:00
1. Solve each exercises from chapter 2
2018-06-11 22:08:57 +00:00
2. Submit a source into your github repository
2018-06-11 21:02:12 +00:00
3. Create an issue and write the address of your source
4. I or somebody will review your source
2018-06-11 22:08:57 +00:00
4-1. Change the code and review again
2018-06-11 21:02:12 +00:00
5. Repeate to the last exercise
2018-06-11 22:08:57 +00:00
# Following challenges are not started yet.
## print "Hello world!" (Planning)
2017-02-01 08:45:02 +00:00
Use argc and argv to print "Hello world!".
```
$ print 3 "Hello world!"
1 Hello world!
2 Hello world!
3 Hello world!
```
2017-02-23 11:53:15 +00:00
2018-06-11 22:08:57 +00:00
## read directory and file (Planning)
2017-02-23 11:53:15 +00:00
2017-03-05 21:13:41 +00:00
make ls tools that just print names of specified directory.
* do not need to get no options
2017-02-23 11:53:15 +00:00
2018-06-11 22:08:57 +00:00
## command argument (Planning)
2017-02-23 11:53:15 +00:00
2017-03-05 21:13:41 +00:00
make ls tools with options and do command argument parsing with getopt, getopt_long
* short options: -l, -a, -d
* long options: --long, --all, --directory
* -l(--long) option prints size, permission, user id, last modified time.
* use getopt, getopt_long to process options
2017-02-23 11:53:15 +00:00
2018-06-11 22:08:57 +00:00
## multi-thread find (Planning)
2017-02-01 21:17:39 +00:00
2017-03-05 21:13:41 +00:00
make find program that has multi-threads
* get file-name and directory-name
* check how many directory exists in target directory
* creates threads as many as directories
* one thread finds a specified file in one directory
* compare performance of one-thread find
2017-02-01 21:17:39 +00:00
2018-06-11 22:08:57 +00:00
## make chat (Planning)
2017-03-05 21:13:41 +00:00
make a 1:1 chatting program for terminal
* make server & client
* support IPv4 and IPv6
2018-06-11 22:08:57 +00:00
## make ftp (Planning)
2017-02-01 21:17:39 +00:00
2017-03-05 21:13:41 +00:00
make ftp server & client
* server-side usage: ``ftp-server``
* client-side usage: ``ftp-client < IPADDR > < FILE-NAME > ``
* print '#' characters to show file-transfer is working
* make server as daemon
* server should support multi-connection
2017-02-01 21:17:39 +00:00
2018-06-11 22:08:57 +00:00
## make streaming player (Planning)
2017-03-08 19:31:02 +00:00
clients send sequential images and server shows images
* convert a gif image into many jpeg images
* client sends the jpeg images
* server receives the jpeg images and shows
* server supports many windows, each windows shows images from a client
* use gtk or win32 APIs
2018-06-11 22:08:57 +00:00
## data-driven code (Planning)
2017-02-01 21:17:39 +00:00
Make serial number certification program
* certificate a serial number file
2017-03-05 21:13:41 +00:00
* read spec.rc file to specify serial number format
2017-02-01 21:17:39 +00:00
* encode user information, user-account number, name, product id, in serial number
* decode the information from the serial number
2017-03-05 21:13:41 +00:00
* serial code is printed in BASE64 code.
* use any encryption algorithm
2017-02-01 21:17:39 +00:00
```
2017-03-05 21:13:41 +00:00
$ cat spec.rc
2017-02-01 21:17:39 +00:00
# field length
2017-03-05 21:13:41 +00:00
user-account 4
user-name 16
product-id 4
2017-02-01 21:17:39 +00:00
2017-03-05 21:13:41 +00:00
$ encode-serial spec.rc
user-account: 1234 < user-input >
user-name: gogostar < user-input >
product-id: 5678 < user-input >
abcd-defg- < output >
2017-02-01 21:17:39 +00:00
$ decode-serial
serial: abcd-defg-xxxx-xxxx < input >
account: 1234
name: gogostar
product: 5678
2017-02-23 11:53:15 +00:00
```
2017-02-01 08:45:02 +00:00
2018-06-11 22:08:57 +00:00
## pool-based memory allocator (Planning)
2017-03-05 21:13:41 +00:00
make a pool-based memory allocator
* create pool as many as number of CPUs in your system
* each thread allocates memory from a pool of its own CPU
* apply your allocator to any multi-thread program and compare performance
* ``LD_PRELOAD=${PATH}/lib/libyourallocator.so.1 app``
2018-06-11 22:08:57 +00:00
## make a shell (Planning)
2017-02-01 08:45:02 +00:00
make your own shell
* features
2017-03-05 21:13:41 +00:00
* pipe
* redirection
2017-02-23 11:53:15 +00:00
* background running
2017-03-05 21:13:41 +00:00
* stdin, stdout, stderr
```
$ myshell
THIS-IS-MYSHELL> ls
a b c
THIS-IS-MYSHELL> ls > files.txt
THIS-IS-MYSHELL> cat ls
a b c
THIS-IS-MYSHELL> ls | cat > files.txt
THIS-IS-MYSHELL> asdf 2> error.txt
THIS-IS-MYSHELL> cat error.txt
command is not found
```
2017-02-01 08:45:02 +00:00
2018-06-11 22:08:57 +00:00
## More challenges (Planning)
2017-03-30 05:51:44 +00:00
Remember! Design is more than the implementation. Think *scalability* !
* http://www.cprogramming.com/challenge.html
* https://www.hackerrank.com/c-programming-test-1
* https://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/PROBLEMS/problems.html
2018-06-11 20:39:31 +00:00
[discussion on reddit ](https://www.reddit.com/r/linuxdev/comments/5r8k6g/new_service_like_the_eudyptula_challenge/ )
* pnpbios
* Writing your own daemon, your own PAM module, writing a custom network interface, writing your own shell
topics:
* file IO
* creating ls
* concurrent
* network
* making chatting program
* memory
* make pool-based memory allocator
* error handling
* toolchain: preprocessor, compiler, linker
* cache
* assembly
* performance
* syncronization