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

C±àÒë»ù´¡

int main(int argc,char *argv[])
argc(argument count):²ÎÊýµÄ¸öÊý£»
argv(argument value):²ÎÊýÖµ
argv[0] :ÎļþÃû
argv[1]£ºµÚÒ»¸ö²ÎÊý£¬argv[2];µÚ¶þ¸ö²ÎÊý£¬ÒÔ´ËÀàÍÆ¡£
±àÒëC
1 µ¥Ô´³ÌÐòµ½¿ÉÖ´ÐгÌÐò
            ±àÒë               Á¬½Ó
Ô´Îļþ(.c)--------->Ä¿±êÎļþ(.o)------->¿ÉÖ´ÐÐÎļþ
 hello.c  -c     howdy        ./howdy
gcc -o:Ö¸¶¨±àÒë³ÌÐòÊä³öµÄ¿ÉÖ´ÐгÌÐòÃû
    -c:ָʾGCCÈ¥±àÒëÔ´´úÂ룬²»ÔÙÓ²ÅÌÉÏÁôÏÂÄ¿±êÎļþ£¬Ìø¹ýµÚ¶þ²½
2 ¶àÔ´Îļþµ½¿ÉÖ´ÐÐÎļþ
gcc -c src1.c src2.c ...
½«n¸öÔ´Îļþ´´½¨¸÷×ÔµÄÄ¿±êÎļþ
gcc scr1.c scr2.c ... -o scr
½«N¸ö³ÌÐò±àÒë³ÉÒ»¸öÄ¿±êÎļþ£¬²¢½«ËûÃÇÁ¬½Óµ½¿ÉÖ´ÐгÌÐòsrc
3 Ô¤´¦Àí
gcc -E:ָʾ±àÒë³ÌÐòÖ»½øÐÐÔ¤´¦Àí²Ù×÷
gcc -E hello.c -o hello.i Ô¤´¦ÀíºóµÄ´úÂë·ÅÔÚ²»ÐèÒªÔ¤´¦ÀíµÄ.i ÎļþÖÐ
4 Éú³É»ã±àÓïÑÔ
gcc -S :ָʵ±àÒëÆ÷Éú³É»ã±à´úÂë
5 ´´½¨¾²Ì¬¿â
¾²Ì¬¿âÊÇһЩ.oÎļþµÄ¼¸ºÎ£¬ËûÃÇÊÇÓɱàÒë³ÌÐò°´ÕÕͨ³£µÄ·½Ê½Éú³ÉµÄ£¬½«³ÌÐòÁ¬½Óµ½¿àÖÔµÄÄ¿±êÎļþºÍ½«³ÌÐòÁ¬½Óµ½Ä¿Â¼ÖеÄÄ¿±êÎļþÊÇÒ»ÑùµÄ£¬¾²Ì¬¿â(archive£©ÓÉar¹ÜÀíÕâЩ¾²Ì¬¿â
¹¹ÔìÒ»¸ö¿â£¬µÚÒ»²¿ÊÇÒª±àÒë¿âÖеÄÄ¿±êÄ£¿é¡£
$gcc -c hellofirst.c hellosecond.c
½¨¿â
$ar -r libhello.a hellofirst.o hellosecond.o
±àÒë²¢Á¬½Ó³ÌÐò
$gcc twohellos.c  libhello.a -o twohellos
Ö´ÐÐ
$./twohellos
6 ´´½¨¹²Ïí¿â£¨.so£©
¹²Ïí¿âÊÇÄ¿±êÎļþµÄ¼¸ºÎ£¬¶ÔÏóÄ£¿éµÄÿ¸öµØÖ·£¨±äÁ¿Ó¦Óúͺ¯Êýµ÷Ó㩶¼ÊÇÏà¶ÔµØÖ·£¬²»ÊǾø¶ÔµØÖ·¡£ÔÊÐíÔÚÔËÐгÌÐòµÄʱºò£¬¶¯Ì¬¼ÓÔÚºÍÖ´Ðй²ÏíÄ£¿é
1 ±àÒë¿âÖеĶÔÏóÄ£¿é
gcc -c -fpic shellofirst.c  shellosecond.c
fpicʹµÃÊä³öµÄ¶ÔÏóÄ£¿éÊÇ°´ÕÕ¿ÉÖض¨Î»·½Ê½Éú³É
2 ¹¹Ôì¹²Ïí¿â
gcc -shared shellofirst.o shellosecond.o -o hello.so
3  gcc stwohellos.c hello.so -o stwohellos
µ«ÊÇÔÚÖ´ÐÐʱ³öÏÖÁË:
./stwohellos
./stwohellos: error while loading shared libraries: hello.so: cannot open shared object file: No such file or directory
Ò»¿ªÊ¼ÎÒÒÔΪȨÏÞ²»¹»£¬¿ÉÊÇ ls -l ÏÔʾ£¬È¨ÏÞÊÇ×ã¹»µÄ¡£
Õë¶ÔÕâÖÖÇé¿öÕâÑùд
gcc


Ïà¹ØÎĵµ£º

C/C+ÓïÑÔstructÉî²ã̽Ë÷ (ת)

C/C+ÓïÑÔstructÉî²ã̽Ë÷     
  
  ×÷ÕߣºËᦻª               ³ö´¦£ºPConline 
  
  1.   structµÄ¾Þ´ó×÷Óà
  ¡¡¡¡Ãæ¶ÔÒ»¸öÈ˵ĴóÐÍC/C++³ÌÐòʱ£¬Ö ......

C\C++²ËÄñÎÊÌ⼯1

´úÂ룺
#include  <iostream>
using namespace std;
class Clock
{
int hour, minute, second;
public:
   Clock(int h, int m, int s) //¹¹Ô캯Êý¶¨Òå £¬ÎÞ·µ»ØÖµÀàÐÍ
   {     
if(s<0) second=0;
       if (s& ......

CÎļþ²Ù×÷Óëfstream¶ÁÈ¡Îı¾ÎļþµÄЧÂʱȽÏ

Õ⼸ÌìÓÉÓÚÒª¶ÁÈ¡½Ï´óµÄÎı¾Îļþ£¬ËùÒԾͱȽÏÁËÒ»ÏÂÁ½ÕßÖ®¼äµÄЧÂÊÎÊÌâ¡£ ËùÒª¶ÁÈ¡µÄÎı¾Îļþ½á¹¹ÎªÃ¿ÐÐÓÉ5¸öÊý×é³É£¬int int int float int£¬²âÊÔµÄÎļþÓÐ33WÐУ¬´óСΪ9M¡£ÏÖÔÚÒª½«Æä¶Áµ½Ò»¸öcube½á¹¹ÌåÀïÃæÈ¥£¬½á¹¹ÌåÓÐ5¸ö³ÉÔ±±äÁ¿ÓëÖ®¶ÔÓ¦¡£ Á½ÖÖ²Ù×÷µÄ´úÂëÈçÏ start = clock();
    ......

c ÓïÑÔÖеÄstatic

1. static ±äÁ¿
¾²Ì¬±äÁ¿µÄÀàÐÍ ËµÃ÷·ûÊÇstatic¡£ ¾²Ì¬±äÁ¿µ±È»ÊÇÊôÓÚ¾²Ì¬´æ´¢·½Ê½£¬µ«ÊÇÊôÓÚ¾²Ì¬´æ´¢·½Ê½µÄÁ¿²»Ò»¶¨¾ÍÊǾ²Ì¬±äÁ¿¡£ ÀýÈçÍⲿ±äÁ¿ËäÊôÓÚ¾²Ì¬ ´æ´¢·½Ê½£¬µ«²»Ò»¶¨ÊǾ²Ì¬±äÁ¿£¬±ØÐëÓÉ static¼ÓÒÔ¶¨Òåºó²ÅÄܳÉΪ¾²Ì¬Íⲿ±äÁ¿£¬»ò³Æ¾²Ì¬È«¾Ö±äÁ¿¡£
2. ¾²Ì¬¾Ö²¿±äÁ¿
¾²Ì¬¾Ö²¿±äÁ¿ÊôÓÚ¾²Ì¬´æ´¢·½Ê½£¬Ëü¾ßÓÐÒÔÏ ......

C/C++ÖеĽṹÌå¶ÔÆëÎÊÌâ(ÄÚ´æ¶ÔÆë)

ÓÉÓÚ³ÌÐòÔËÐÐʱռÓõÄÄÚ´æ¹ý´ó£¬ËùÒÔÏë°ì·¨¸ø³ÌÐòÊÝÉí¡£
ÔÚµ÷ÊÔÖз¢ÏֽṹÌåÕ¼ÓõÄsize¾¹È»ºÍÔ¤ÏëµÄ²»Ò»Ñù£¬Ô­À´……
¿´¿´ÏÂÃæ½²µÄ°É£¬¿Ï¶¨»á²»Í÷´Ë¿´Å¶£¡
1,±ÈÈç:
struct{
short a1;
short a2;
short a3;
}A;
struct{
long a1;
short a2;
}B;
sizeof(A)=6, sizeof(B)=8,Ϊʲô£¿
×¢£ºsizeof(sho ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ