CÉî¶È½âÆÊÎÊÌâ´úÂë·ÖÎö±Ê¼Ç1
#include <stdio.h>
int main()
{
int a[5]={1,2,3,4,5};
int *ptr1=(int*)(&a+1);
int *ptr2=(int*)((int)a+1);
printf("%p,%x,%p\n",(int)a,*(ptr2+1),ptr1);//(int*)(&a));
printf("%d\n",(int*)(&a-16));
printf("%d,%x\n",ptr1[-1],*ptr2);
return 0;
}
ÔÚÁ½¶ÎºÜ¶ÌµÄ³ÌÐòÉϺÄÁËÕû¸öÍíÉÏ£¬²»¹ý¸Ð¾õ»¹²»´í£¬ÍêÈ«¿¿×Ô¼ºµ÷ÊÔ·ÖÎöµÄ¹ý³ÌºÜÓгɾ͸С£
²»¹ýgdb»¹Ò»µã¶¼²»»áÓã¬ÊÔ¹ýÊÖ²áÀïµÄgdb program£¬µ«ÊÇÖ®ºó list ³öÀ´µÄÎļþÃûÈ´ÊÇij"Start.S"£¬²ÎÊýµÄÓ÷¨»¹Ã»Àí½â£¬µ±Ê±Ò²Ã»¹ÜÕâô¶à£¬¼±×ÅÏëÒª¸ãÇå³þÕâÁ½¶Î³ÌÐòµÄÔÀí£¬ËùÒÔ¾ÍÖ±½ÓÓÃprintfÀ´µ÷ÊÔÁË¡££¨Ï£ÍûÓз¹ýµÄ
¸ßÊÖÄÜÖ¸µãһϣ¬¼òµ¥ËµÒ»Ï³£ÓòÎÊýµÄÉèÖþÍÐУ¬¸Ð¼¤Íò·Ö£¡
£©
ÓÚÊÇ£¬Í¨¹ýÐÞ¸ÄÁËN´ÎµÚÒ»¸öprintfµÄ²ÎÊý£¬ÊÕ¼¯µ½ÒÔÏÂÊý¾Ý£º
1.(int)a == (int*)(&a) == &a
2.(int*)(&a+1) - 14h == (int)a£¬
(int*)(&a+2) - 28h == (int)a
3.int a[6]={1,2,9,4,5,6}ʱ£¬
(int*)(&a+1) - 15h == (int)a£¬
(int*)(&a+2) - 30h == (int)a
4.
ptr1[-1]==5,
ptr1[-2]==4,
ptr1[-3]==3,
ptr1[-4]==2,
ptr1[-5]==1
5.Ìí¼Ó£º
int i;
for(i=0;i<20;i++)
{
unsigned *p=(unsigned*)((int)a+i);
printf("%lx\n",*p);
}
µÃ³ö£º
1
2000000
20000
200
2
3000000
30000
300
3
4000000
40000
400
4
5000000
50000
500
5
8d000000
cd8e0000
a0cd8f00
int i;
for(i=0;i<20;i++)
{
char *p=(char*)((int)a+i);
printf("%x",*p);
}
µÃ³ö£º10002000300040005000
ÍÆÀí½á¹û£º
Ò»¡¢¿ÉÒÔµÃÖª(&a+1)±ÈaµÄµØÖ·¸ß³ö0x14h,Ò²¾ÍÊÇ20£¬¶ø¸ÕºÃ5¸öintÐÍËùÕ¼µÄÄÚ´æÒ²ÊÇ20£¬ÔÙ½áºÏÌõ¼þ3¿ÉÒÔÍƶϳö
int *ptr1=(int*)(&a+1);´Ë¾äÊÇÒª°Ñptr1Ö¸ÏòÊý×éaºó1×Ö½Ú£¬¶øptr1[-x]ÔòÊÇ´Ó(£¦a£«1)ºóÍË£¬ÒòΪptr1ÊÇint *£¬ËùÒÔÿ¼õ1¾ÍÏòÇ°ÒÆ4×Ö½Ú¡£
¶þ¡¢(&a+x)»áÒÔ x*sizeof(a) ÏßÐÔµÝÔö¡£
Èý¡¢ÒòΪÎÒµÄÊÇ32λ»ú£¬unsignedºÍint´óС¶¼ÊÇ4×Ö½Ú£¬ËùÒÔ²âÊÔ´úÂëºÍÔ³ÌÐòµÄunsigned *ºÍint *¶¼ÊÇÿ´Î´ÓÄÚ´æ¶ÁÈ¡4×Ö½Ú£¬¶øÇÒ¿ÉÒÔÍÆÀí³öÎ
Ïà¹ØÎĵµ£º
#include <stdio.h>
#include <unistd.h>
#define FOO "foo"
int main(void)
{
if(!access(FOO, F_OK))
{
if(!unlink(FOO))
{
}
else
{
printf("remove %s failed\n", FOO);
}
}
else
{
printf("%s not existed\ ......
QT
http://www.trolltech.com
http://www.qiliang.net/qt.html
QtÊÇTrolltech¹«Ë¾µÄÒ»¸ö¶àƽ̨µÄC++ͼÐÎÓû§½çÃæÓ¦ÓóÌÐò¿ò¼Ü¡£ËüÌṩ¸øÓ¦ÓóÌÐò¿ª·¢Õß½¨Á¢ÒÕÊõ¼¶µÄͼÐÎÓû§½çÃæËùÐèµÄËùÓù¦ÄÜ¡£QtÊÇÍêÈ«ÃæÏò¶ÔÏóµÄºÜÈÝÒ×À©Õ¹£¬²¢ÇÒÔÊÐíÕæÕýµØ×é¼þ±à³Ì¡£×Ô´Ó1996ÄêÔçЩʱºò£¬Qt½øÈëÉÌÒµÁìÓò£¬ËüÒѾ³ÉΪȫÊÀ½ç·¶ ......
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Ò»Ñù¡£ºêÓÐ
Ò»¸öºÜ´óµÄ×÷Ó㬾ÍÊÇ×Ô¶¯ÎªÎÒÃDzúÉú´úÂë¡£Èç¹û˵ģ°å¿ÉÒÔΪÎÒÃDzúÉú¸÷ÖÖÐͱðµÄ´úÂë(ÐͱðÌæ»»)£¬
ÄÇôºêÆäʵ¿ÉÒÔΪÎÒÃÇÔÚ·ûºÅÉϲúÉúеĴúÂë(¼´·ûºÅÌæ»»¡¢Ôö¼Ó)¡£
¹ØÓÚºêµÄһЩÓï·¨ÎÊÌ⣬¿É ......
Ò»°ã±äÁ¿¶¨ÒåÔÚ*.cÎļþÖÐ,¶ø*.hÎļþÖÐÉùÃ÷±äÁ¿»òº¯ÊýÃûºÍ·ûºÅÃû.
±ÜÃæÖظ´±àÒëµÄ½â¾ö·½·¨:
±ÈÈçÄãÓÐÁ½¸öCÎļþ£¬ÕâÁ½¸öCÎļþ¶¼includeÁËͬһ¸öÍ·Îļþ¡£¶ø±àÒëʱ£¬ÕâÁ½¸öCÎļþ¶¼Òªµ÷ÓÃͬһ¸öÍ·ÎļþÈ¥±àÒ룬Öظ´±àÒë»á²úÉú´óÁ¿µÄÉùÃ÷³åÍ»¡£½â¾öÕâ¸öÎÊÌâµÄ·½·¨Ê¹ÓÃ#ifndef, #endif, #endif¡£
&nbs ......