Chinaunix首页 | 论坛 | 博客
  • 博客访问: 43203
  • 博文数量: 18
  • 博客积分: 400
  • 博客等级: 下士
  • 技术积分: 160
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-03 12:27
文章分类
文章存档

2010年(4)

2008年(14)

我的朋友
最近访客

分类: C/C++

2008-12-22 22:06:12

Learning C

If you don't know C and plan to use it for osdeving, it might be profitable to begin with some C language exercises. A good start (you still need to find tutorials, these are just exercises):

  • program that writes a string, asks for your name, writes two line breaks and writes another string and the provided name;
  • implement strcopy(), strncopy(), strncmp() and other string manipulation functions. What is a buffer overflow?
  • implement memmove() or memcpy(). Can you do it with inline assembly so it be faster?
  • use inline assembly to perform CPUID and interpret the results;
  • use typedefs to name uint32 for a 32-bit unsigned integer type; what type is signed 16-bit?
  • use structs and pointers to implement a singly linked lists.
  • divide the program with singly linked lists to main.c, list.c and list.h. What is a header guard?
  • learn about inline, static, volatile; ternary operator; casts;
  • use C preprocessor to write MAX, MIN macros; to print out the current function name, line number;
  • use C preprocessor to write a log function which takes a level for the first argument, and uses printf() on the rest of the arguments if the level is higher or equal to current logging threshold.


原文地址:http://wiki.osdev.org/C#Learning_C
阅读(946) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~