摘要:
1 #include 2 #include 3 #include 4 5 #define MAX 20 6 7 8 typedef struct stack{ 9 char item; 10 struct stack *next; 11 }stack; 12 13 char gettop_s(stack *h) //得到栈顶元素 14 { 15 char ch; 16 17 ch = h->item; 18 19 return ch; 20 } 21 22 stack * out_s(sta... 阅读全文
摘要:
十进制转换八进制,二进制,十六进制: 1 #include 2 #include 3 #include 4 5 #define MAX 20 6 7 int bin_val[MAX]; //存放十进制转换成二进制的结果 8 9 int get_int() 10 { 11 int in; 12 while(scanf("%d",&in) == -1){ 13 printf("please input a num\n"); 14 while(getchar() != '\n') ; 15 } 1... 阅读全文
摘要:
1 #include 2 #define MAX 20 3 int main() 4 { 5 int a[4] = {3,5,8,11}; 6 int b[7] = {2,6,8,9,11,15,20}; 7 int i = 0,j = 0; 8 int c[MAX]; 9 int tmp = 0;10 11 while(i < 4 && j < 7){12 if(a[i] < b[j])13 c[tmp++] = a[i++];14 else15 c[tmp++]... 阅读全文
摘要:
答案是肯定的,可以一起用。 因为很多人误解了const的真正含义,很多初学者认为const修饰的就是常量,而常量不会改变,而既然不会改变,那volatile就没有意义。 但是实际上这正是对const的误读,const其实只是一种限制约定,也就是某个东西X不能由const修饰的变量来修改,但是这个X仍然可以被其他非const修饰的变量来修改,比如int x;int* p = &x;const int* q = &x;*p=0; //允许*q=0; //错误 虽然p和q指向同一块内存,但是q的const并不能限制p的写入,也就是说const只是限制了q的写入,... 阅读全文
摘要:
what do you do for living?一般用在问对方的工作。如果直接说“what is your job?”会显得有点生硬了。i was wondering if you can tell me how i could get to the somebody'house请问怎么去某人的家。is this your first time in somewhere?这是你第一次来到某个地方吗?somewhere 要有一个升调;do you like it here?你喜欢这里吗?how do you like it so far?你喜欢这里吗?how are you doin 阅读全文
摘要:
#include int creat(const char *pathname, mode_t mode); 若成功则返回为只写打开的文件描述符,若出错则返回-1; 有时候我们使用creat函数的时候可能会得不到我们想要的结果。例如:creat("foo",0666) 当我们使用次函数的目的创建一个文件——foo,foo的属性为 -rw-rw-rw-; 但是我们执行完creat函数之后可能会发生其他的结果,笔者的系统是REHL5.1,当我执行完creat函数之后foo的属性为:-rw-r--r--; 这是为什么呢? 如果你想知道为什么,就在命令行里执行umask看一下吧; 阅读全文
摘要:
Cocktail 鸡尾酒 It is quite usual to drink cocktails before lunch and dinner in America and somewhat less usual, except in California, to drink wine with a meal. You can either have a cocktail in the bar, if there is one, while you wait for a table or for friends, or you can have one served before y... 阅读全文
摘要:
When you want to change something in your life, it can feel overwhelming. Whether it’s losing 50lbs or switching careers, starting a side business or spring cleaning the home, it might be a change you’re desperately keen to make … but getting started is really tough.You don’t have to take huge, swee 阅读全文
摘要:
相信大部分在Unix/Linux下编程的程序员手头上都有《Unix环境高级编程》(APUE)这本超级经典巨著。作者在该书中讲解dup/dup2之前曾经讲过“文件共享”,这对理解dup/dup2还是很有帮助的。这里做简单摘录以备在后面的分析中使用:Stevens said:(1) 每个进程在进程表中都有一个记录项,每个记录项中有一张打开文件描述符表,可将视为一个矢量,每个描述符占用一项。与每个文件描述符相关联的是: (a) 文件描述符标志。 (b) 指向一个文件表项的指针。(2) 内核为所有打开文件维持一张文件表。每个文件表项包含: (a) 文件状态标志(读、写、增写、同步、非阻塞等)。 (b) 阅读全文
摘要:
There used to be an old joke in America that people should take a bath once a week, whether they need one or not. In fact, though, Americans generally take a bath-or more commonly(通常地), a shower-every day. But in contrast to some cultures, most Americans get their shower in the morning, so they can. 阅读全文