淡水求咸

博客园已经停止更新,请移步 http://lovecjh.com/

导航

2012年10月29日

函数名与函数指针

摘要: 先来看一个程序:/************************************************************* 函数指针与函数名**************************************************************/#include <iostream>using namespace std;int max(int, int);int main(){ cout<<max(1, 2)<<endl; cout<<(*max)(1, 2)<<endl; cout<&l 阅读全文

posted @ 2012-10-29 21:47 深圳彦祖 阅读(330) 评论(0) 推荐(0) 编辑

一个fork的面试题

摘要: 这篇文章转自酷壳皓哥,原文地址在这。 前两天有人问了个关于Unix的fork()系统调用的面试题,这个题正好是我大约十年前找工作时某公司问我的一个题,我觉得比较有趣,写篇文章与大家分享一下。这个题是这样的: 题目:请问下面的程序一共输出多少个“-”?#include <stdio.h>#include <sys/types.h>#include <unistd.h> int main(void){ int i; for(i=0; i<2; i++){ fork(); printf("-"); } return 0;} 如果你对for 阅读全文

posted @ 2012-10-29 09:15 深圳彦祖 阅读(330) 评论(0) 推荐(0) 编辑