C puzzles
Authentication
Login with:New JS-Kit account
Google Friend Connect
Twitter account
FriendFeed account
Yahoo account
Blogspot URL
JS-Kit account
Haloscan account
OpenID
Dear visitor,
Thanks for your interest in C programming.
In this page, you will find a
list of interesting C programming questions/puzzles,
These programs listed are the ones which I have received as
e-mail forwards from my friends, a few I read in some books, a few from the
internet, and a few from my coding experiences in C.
Most of the programs are meant to be compiled, run and
to be explained for their behaviour. The puzzles/questions can be broadly
put into the following categories:
General typo errors, which C programmers do often and are
very difficult to trace.
Small programs which are extremely hard to understand at the first
examination. These questions make a good excercise of reading and understanding
effecient code written by others.
I have used Gnu/Linux/gcc for all of them.
The order in which the programs appear doesn't have
any relation with the level of difficulty.
Please feel free to contact me if you need any help in solving the problems.
My contact info. is available here
And you might be interested in a few references for C programming
,
which I personally found very interesting.
If you are preparing for campus interviews, you might find the following
link interesting:
http://placementsindia.blogspot.com
Regards,
Gowri Kumar
C puzzles
The expected output of the following C program
is to print the elements in the array. But when
actually run, it doesn't do so.
#include
<stdio.h>
#define
TOTAL_ELEMENTS
(
sizeof
(
array
)
/
sizeof
(
array
[
0
]))
int
array
[] =
{23
,34
,12
,17
,204
,99
,16
};
int
main
()
{
int
d
;
for
(d
=-
1
;d
<=
(TOTAL_ELEMENTS
-
2
);d
++
)
printf
(&q
相关文档:
Linux下C语言编程基础(Makefile)
2005-01-18 10:28:23 来自:赛迪网
假设我们有下面这样的一个程序,源代码如下:
/* main.c */
#include "mytool1.h"
#include "mytool2.h"
int main(int argc,char **argv)
{
mytool1_print("hello");
mytool2_print(&q ......
(转)C/C++ 宏详解 收藏
众多C++书籍都忠告我们C语言宏是万恶之首,但事情总不如我们想象的那么坏,就如同goto一样。宏有
一个很大的作用,就是自动为我们产生代码。如果说模板可以为我们产生各种型别的代码(型别替换),
那么宏其实可以为我们在符号上产生新的代码(即符号替换、增加)。
关于宏的一些语法问题,可 ......
Netbeans经常会出现写代码的时候代码提示出不来的情况,甚至是代码根本没错,编译都能通过,但是代码帮助就提示我说我有错误,在下面画条红线!而这些问题Eclipse没有出现过!而且Eclipse有专门的CDT插件开发小组,很好强大。 ......
定义按值传递和按引用传递这两个术语是重要的。
按值传递意味着当将一个参数传递给一个函数时,函数接收的是参数的一个副本。因此,如 果函数修改了该参数,仅改变副本,而原始值保持不变。按引用传递意味着当将一个参数传递给一个函数时,函数接收的是参数的内存地址,而不是参数的副本。因 此,如果函数修改了该参数,调 ......