Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

c´úÂ룺µç»°ºÅÂëºÍ×Öĸת»»

ÕâÁ½Ìì¿´µ½ÓÐÈËÌÖÂ۵绰¼üÅÌÉϵÄ×Öĸ¡¢ºÅÂëºÍ×ÖĸµÄת»»£¬ÎÒÒ²Ëæ±ãдÁËÒ»¶Î
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_LEN 15
char *tbl_itoa[] =
{
"0", // 0
"1", // 1
"ABC", // 2
"DEF", // 3
"GHI", // 4
"JKL", // 5
"MNO", ......

Eclipse¶ÔC/C++µÄÖ§³Ö±ÈNetbeansºÃ¶àÁË

Netbeans¾­³£»á³öÏÖд´úÂëµÄʱºò´úÂëÌáʾ³ö²»À´µÄÇé¿ö£¬ÉõÖÁÊÇ´úÂë¸ù±¾Ã»´í£¬±àÒë¶¼ÄÜͨ¹ý£¬µ«ÊÇ´úÂë°ïÖú¾ÍÌáʾÎÒ˵ÎÒÓдíÎó£¬ÔÚÏÂÃæ»­ÌõºìÏߣ¡¶øÕâЩÎÊÌâEclipseûÓгöÏÖ¹ý£¡¶øÇÒEclipseÓÐרÃŵÄCDT²å¼þ¿ª·¢Ð¡×飬ºÜºÃÇ¿´ó¡£ ......

C/C++ÖеÄÎļþ²Ù×÷

1.fopen()
¡¡¡¡fopenµÄÔ­ÐÍÊÇ£ºFILE *fopen(const char *filename,const char *mode)£¬fopenʵÏÖÈý¸ö¹¦ÄÜ
ΪʹÓöø´ò¿ªÒ»¸öÁ÷ 
°ÑÒ»¸öÎļþºÍ´ËÁ÷ÏàÁ¬½Ó 
¸ø´ËÁ÷·µ»ØÒ»¸öFILEÖ¸Õë
²ÎÊýfilenameÖ¸ÏòÒª´ò¿ªµÄÎļþÃû£¬mode±íʾ´ò¿ª×´Ì¬µÄ×Ö·û´®£¬ÆäȡֵÈçϱí
×Ö·û´® º¬Òå 
"r" ÒÔÖ»¶Á·½Ê½´ò¿ªÎļþ  ......

C/C++Êý×éÃûÓëÖ¸ÕëÇø±ðÉîÈë̽Ë÷

 
ÒýÑÔ
¡¡¡¡Ö¸ÕëÊÇC/C++ÓïÑÔµÄÌØÉ«£¬¶øÊý×éÃûÓëÖ¸ÕëÓÐÌ«¶àµÄÏàËÆ£¬ÉõÖÁºÜ¶àʱºò£¬Êý×éÃû¿ÉÒÔ×÷ΪָÕëʹÓá£ÓÚÊǺõ£¬ºÜ¶à³ÌÐòÉè¼ÆÕ߾ͱ»¸ãºýÍ¿ÁË¡£¶øÐí¶àµÄ´óѧÀÏʦ£¬ËûÃÇÔÚCÓïÑԵĽÌѧ¹ý³ÌÖÐÒ²´íÎóµÃ¸øÑ§Éú½²½â£º"Êý×éÃû¾ÍÊÇÖ¸Õë"¡£ºÜÐÒÔË£¬ÎҵĴóѧÀÏʦ¾ÍÊÇÆäÖÐÖ®Ò»¡£Ê±ÖÁ½ñÈÕ£¬ÎÒÈÕ¸´Ò»ÈյؽøÐÐ×ÅC/C++Ï ......

C λ²Ù×÷

 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
C λ²Ù×÷
ʱ¼ä£º2009-10-9
×÷Õߣºsofa120
×¢£º    ×ªÔØÇë˵Ã÷³ö´¦
/////////////////////////// ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ