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
相关文档:
一般在调试打印Debug信息的时候, 需要可变参数的宏. 从C99开始可以使编译器标准支持可变参数宏(variadic macros), 另外GCC也支持可变参数宏, 但是两种在细节上可能存在区别.
1. __VA_ARGS__
__VA_ARGS__ 将 "..." 传递给宏 . 如
......
学习C语言时,用字符串的函数例如stpcpy()、strcat()、strcmp()等,要包含头文件string.h
学习C++后,C++有字符串的标准类string,string类也有很多方法,用string类时要用到string.h头文件。
我现在看vc的书上也有CString类,这个要包含什么,怎么用?
我现在很迷惑,这两个 string.h有什么区别。是怎么回事
且看 ......
1.fopen()
fopen的原型是:FILE *fopen(const char *filename,const char *mode),fopen实现三个功能
为使用而打开一个流
把一个文件和此流相连接
给此流返回一个FILE指针
参数filename指向要打开的文件名,mode表示打开状态的字符串,其取值如下表
字符串 含义
"r" 以只读方式打开文件 ......
检查空格字符
#include <ctype.h>
int isspace ( int c );
http://www.cplusplus.com/reference/clibrary/cctype/isspace/
Checks if parameter c is a white-space character.For the purpose of this function, standard white-space characters are:
' '
(0x20)
space (SPC)
'\t'
(0x09)
horizontal tab ......