找回密码
 注册
搜索
查看: 1673|回复: 2

[讨论] 据说某手机公司的笔试题(c语言),有兴趣的看看

[复制链接]
发表于 2006-2-13 17:16:00 | 显示全部楼层 |阅读模式
1.      Write a function that prints the binary representation of an unsigned integer using only putchar() for output
2.      Memory Management/Pointer manipulation
Write a function that allows you to remove a substring from a string and returns a new string that uses only the amount of storage needed
Assume: All arguments are always valid
     The original string should remain untouched
Use the following function prototype
char * remove_substr(char *str, int pos, int length);
3.      Data structures
Implement a circular queue of size n using an array. Use the given fragments for your implementation
  typedef stuct QUEUE{
         int head, tail;
         void * data[N];
  }queue;
  
  void init-queue()
  {
  }
  
  int queue(void *data)
  {
  }
  void * dequeue()
  {
  }
4.      Problem solving/operating systems
A multitasking OS has a producer program that writes data to a buffer and consumer one that reads that data and prints it. Show the work that needs to be done to make sure this works smoothly.
5.      C syntax
Identify all the errors in the following piece of C code. Assuming you fix it so it compiles correctly. What would it print? (be sure to specify any assumptions)
  void init_array(unsigned int array[])
  {
         int size = sizeof(array);
         int i;
         for(i=0; i<size; i++)
         array=-1;
  }
  void main()
  {
         char * string=”Here is rather long constant to fit my needs”;
         char * another_string;
         unsigned int array[11];
         init_array(&array[0]);
         another_string=(char*)malloc(strlen(string));
         strcpy(another_string,string);
         for(i=0; i<=40; i+=4){
         array[i/4]=int(*)string;
         printf(“%s”, (char *) array);
    }
发表于 2006-2-17 17:15:00 | 显示全部楼层
是YUHUATEL的吗?
点评回复

使用道具 举报

发表于 2006-3-31 13:18:00 | 显示全部楼层
mark[em05[em01]
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-11-23 06:15 , Processed in 0.044912 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表