一道c面试题
int arr[]={6,7,8,9,10};
int *ptr=arr;
*(ptr++)+=123;
printf("%d,%d",*ptr,*(++ptr));
此题最后的结果是8,8.
乍看结果应该是7和8。
原理:
因为它们作为printf的参数,函数printf从左往右读取,然后将先读取放到栈底,最后读取的放在栈顶,处理时候是从栈顶开始的,所有我们看见的结果是,从右边开始处理的。
相关文档:
如果C++调用一个C语言编写的.DLL时,当包括.DLL的头文件或声明接口函数时,应加extern "C" { }。
如:
头文件cExample.h
#include <stdio.h>
#ifndef C_EXAMPLE_H
#define C_EXAMPLE_H
int add(int x,int y);
#endif
函数实现文件cExample.c(注意是.c文件)
#include<stdio.h>
#include "cExample ......
/*=================================
.* The Standard include file.
.*
.*===============================*/
#include <stdio.h>
#include <stdlib.h>
/*=================================
.*
.* The extend include file.
.*
.*===============================*/
#include "sqlit ......
总是被同学们问到,如何学习C和C++才不茫然,才不是乱学,想了一下,这里给出一个总的回复。
一家之言,欢迎拍砖哈。
1、可以考虑先学习C.
大多数时候,我们学习语言的目的,不是为了成为一个语言专家,而是希望成为一个解决问题的专家。做一个有用的程序员,做一个赚钱的程序员。我们的价值,将体现在客 ......
pFn t1(void);
pFn t2(void);
int main()
{
pFn fn = t1 ;
while(1){
fn = fn(); //这个,大家看清楚了
}
}
pFn t1()
{
printf("t1\n");
return t2 ;
}
pFn t2()
{
printf("t2\n");
return t1 ;
}
请问,想通过编译,pFn函数指针类型 ......