Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : c

CÓïÑÔÔ¤±àÒë³öÀ´ÃüÁî

Ò»¡¢ºê¶¨Òå(²»´ø²ÎÊýµÄºê¶¨Òå,´ø²ÎÊýµÄºê¶¨Òå)
1.±àÒëÔ¤´¦Àí¾ÍÊǶÔCÔ´³ÌÐò½øÐбàÒëÇ°,ÓÉ"±àÒëÔ¤´¦Àí³ÌÐò"¶ÔÔ¤´¦ÀíÃüÁîÐнøÐд¦ÀíµÄ¹ý³Ì¡£
2.CÓïÑÔÖÐ,·²ÊÇÒÔ"#"¿ªÍ·µÄÐÐ,¶¼³ÆΪ"±àÒëÔ¤´¦Àí"ÃüÁîÐС£
CÓïÑÔÖеıàÒëÔ¤´¦ÃüÁîÓÐ:#define,#undef,#include,#if,#else,#elif,#endif,#ifdef,#ifndef,#line,#pragma,#error¡£ÕâЩԤ´¦ÀíÃüÁî×é³ÉµÄÔ¤´¦ÀíÃüÁîÐбØÐëÔÚÒ»ÐеĿªÍ·ÒÔ"#"ºÅ¿ªÊ¼,ÿÐеÄδβ²»µÃ¼Ó";"ºÅ,ÒÔÇø±ðÓÚCÓï¾ä¡¢¶¨ÒåºÍ˵Ã÷Óï¾ä¡£
3.²»´ø²ÎÊýµÄºê¶¨Òå:ÃüÁîµÄÒ»°ãÐÎʽΪ:
#define ±êʶ·û ×Ö·û´®
¶¨ÒåÖеÄ"±êʶ·û"ΪÓû§¶¨ÒåµÄ±êʶ·û,³ÆΪºêÃû¡£ÔÚÔ¤±àÒëʱ,CÔ¤±àÒë³ÌÐò½«³öÏֵĺêÃûÌæ»»³É"×Ö·û´®"µÄÄÚÈÝ,ÕâÒ»¹ý³ÌÒ²³ÆΪºêÕ¹¿ª¡£
4.´ø²ÎÊýµÄºê¶¨Òå:ÃüÁîµÄÒ»°ãÐÎʽΪ
#defineºêÃû(ÐÎʽ²ÎÊý) ×Ö·û´®
¶¨ÒåÖеÄ"×Ö·û´®"Ó¦°üº¬À¨ºÅÖÐËùÖ¸¶¨µÄÐÎʽ²ÎÊý¡£×¢ÒâºêÃûÓëÀ¨ºÅÖ®¼ä²»Òª¼Ó¿Õ¸ñ,·ñÔò¾Í³ÉΪ²»´ø²ÎÊýµÄºê¶¨ÒåÁË¡£
5.Ô¤±àÒëʱ,Óöµ½´øʵ²ÎµÄºêÃû,Ôò°´ÃüÁîÐÐÖÐÖ¸¶¨µÄ×Ö·û´®´Ó×óµ½ÓÒ½øÐÐÖû»,Ô­ÔòÊÇ:
Óöµ½Êµ²ÎÔòÒÔʵ²Î´úÌæ,·ÇÐβÎ×Ö·ûÔ­Ñù±£Áô,´Ó¶øÐγÉÕ¹¿ªºóµÄÄÚÈÝ¡£
¶þ¡¢“Îļþ°üº¬”´¦Àí
1.Îļþ°üº¬µÄÒ»°ãÐÎʽΪ:
#include"Í·ÎļþÃû"#include<Í·Î ......

CÓïÑÔÖÐûÓк¯ÊýÖØÔصĸÅÄî

CÓïÑÔÖÐûÓк¯ÊýÖØÔصĸÅÄ£¡
CÓïÑÔÖÐûÓк¯ÊýÖØÔصĸÅÄ£¡
½ñÌìMSNȺÖÐÓиöÈËÎÊÎÒCÓïÑÔµÄÎÊÌ⣺
     £¨Á½¸öº¯ÊýʵÏֵŦÄÜÏàͬ
       µ«ÊÇËüÃDzÎÊýµÄ¸öÊý²»Í¬
       ÎÒÓÃÒ»¸öº¯Êý°ÑÕâ¸öÁ½¸öº¯Êý·âÆðÀ´
        ÎÒÕâ¸öº¯ÊýµÄ²ÎÊýÔõôÉèÖã¿
       Ö¸µãÒ»ÏÂ
       лÀ²
        ÎÒÕâ¸öº¯Êýͨ¹ýºêÀ´Çø·ÖÄÇÁ½¸öº¯Êý£©
»Ø´ðµÄʱºò£¬ÎÒÌáµ½Á˺¯ÊýµÄÖØÔØ£¬»¹Ç¿µ÷CÓïÑÔÒ²Óк¯ÊýµÄÖØÔØ¡£囧ÁË¡£ÉÏÍøÒ»²é²Å·¢ÏÖCÖÐûÓк¯ÊýµÄÖØÔصĸÅÄ¶øÊÇC++ÖвÅÓС£ÓÉÓÚ±àÒëÆ÷µÄÎÊÌ⣬CÖв»ÔÊÐíº¯ÊýͬÃû¡£¡£µ«ÊÇC++ʵÏÖÁËÔÚ±àÒëµÄʱºòµÄ±ä»¯¡£
ÖÁÓÚʵÏÖÉÏÃæÄǸöÈËÎʵÄÎÊÌ⣬Ï൱ÓÚ ......

C/C++ÖеÄstatic

C++ÖеÄStaticÓÐÁ½¸ö×÷Óá£
1¡¢ ¾²Ì¬¾Ö²¿±äÁ¿ 
   ¾²Ì¬¾Ö²¿±äÁ¿ÔÚº¯ÊýÄÚ¶¨Òå ËüµÄÉú´æÆÚΪÕû¸öÔ´³ÌÐò£¬µ«ÊÇÆä×÷ÓÃÓòÔڸú¯ÊýÄÚ£¬Ö»ÄÜÔÚ¶¨Òå¸Ã±äÁ¿µÄº¯ÊýÄÚʹÓøñäÁ¿¡£ ÔÊÐí¶Ô¹¹ÔìÀྲ̬¾Ö²¿Á¿¸³³õÖµ£¬Èôδ¸³ÒÔ³õÖµ£¬ÔòÓÉϵͳ×Ô¶¯¸³ÒÔ0Öµ¡£ 
void fun1()
{
static int i = 0;
cout << ++i << endl;
}
int main()
{
for(int i = 0; i < 5; i++)
{
fun1();
}

Output :
1
2
3
4
2¡¢¾²Ì¬È«¾Ö±äÁ¿ 
  È«¾Ö±äÁ¿Ç°ÔÙ¼ÓÉÏstatic ¾Í³ÉÁ˾²Ì¬µÄÈ«¾Ö±äÁ¿¡£È«¾Ö±äÁ¿±¾Éí¾ÍÊǾ²Ì¬´æ´¢·½Ê½£¬ ¾²Ì¬È«¾Ö±äÁ¿µ±È»Ò²ÊǾ²Ì¬´æ´¢·½Ê½¡£È«¾Ö±äÁ¿×÷ÓÃÓòÊÇÕû¸öÔ´³ÌÐò£¬¶ø¾²Ì¬È«¾Ö±äÁ¿×÷ÓÃÓòÈ·ÊǸÃÎļþ¡£¾²Ì¬º¯ÊýÀàËÆ¡£
......

C/C++ÖеÄstatic

C++ÖеÄStaticÓÐÁ½¸ö×÷Óá£
1¡¢ ¾²Ì¬¾Ö²¿±äÁ¿ 
   ¾²Ì¬¾Ö²¿±äÁ¿ÔÚº¯ÊýÄÚ¶¨Òå ËüµÄÉú´æÆÚΪÕû¸öÔ´³ÌÐò£¬µ«ÊÇÆä×÷ÓÃÓòÔڸú¯ÊýÄÚ£¬Ö»ÄÜÔÚ¶¨Òå¸Ã±äÁ¿µÄº¯ÊýÄÚʹÓøñäÁ¿¡£ ÔÊÐí¶Ô¹¹ÔìÀྲ̬¾Ö²¿Á¿¸³³õÖµ£¬Èôδ¸³ÒÔ³õÖµ£¬ÔòÓÉϵͳ×Ô¶¯¸³ÒÔ0Öµ¡£ 
void fun1()
{
static int i = 0;
cout << ++i << endl;
}
int main()
{
for(int i = 0; i < 5; i++)
{
fun1();
}

Output :
1
2
3
4
2¡¢¾²Ì¬È«¾Ö±äÁ¿ 
  È«¾Ö±äÁ¿Ç°ÔÙ¼ÓÉÏstatic ¾Í³ÉÁ˾²Ì¬µÄÈ«¾Ö±äÁ¿¡£È«¾Ö±äÁ¿±¾Éí¾ÍÊǾ²Ì¬´æ´¢·½Ê½£¬ ¾²Ì¬È«¾Ö±äÁ¿µ±È»Ò²ÊǾ²Ì¬´æ´¢·½Ê½¡£È«¾Ö±äÁ¿×÷ÓÃÓòÊÇÕû¸öÔ´³ÌÐò£¬¶ø¾²Ì¬È«¾Ö±äÁ¿×÷ÓÃÓòÈ·ÊǸÃÎļþ¡£¾²Ì¬º¯ÊýÀàËÆ¡£
......

Visual Studio 2005´´½¨C³ÌÐò

ÔÚVisual Studio 2005Öд´½¨C³ÌÐòµÄ·½·¨Îª£º 
      1.  File ->New Project -> Visual C++ -> Win32 -> Win32 Console Application,È»ºóÔÚÏÂÃæµÄNameÀ¸Ð´ÉÏProjectÃû³Æ,LocationÀ¸Ð´ÉÏÎļþµÄ´æ·Å·¾¶,µãOK°´Å¥½øÈëApplication Settings,ÔÚAddtional optionsÖÐÑ¡ÔñEmpty project,µãFinish°´Å¥Íê³É¹¤³ÌµÄ´´½¨¡£
      2.  ÔÚvisual studio ÊÓͼµÄÓÒÉϽǵÄSolution ExplorerÖУ¬ÔÚSource FilesÖд´½¨c³ÌÐò£¬stepΪ£ºÓÒ¼üµã»÷Source Files,ÔÚmenuÖÐÑ¡ÔñAdd-> New Item£¬Ñ¡ÔñC++ File£¬²¢ÔÚÏÂÃæµÄName´¦¼üÈëfirst.c£¬location´¦Ð´ÉϳÌÐòÃû³ÆºÍ³ÌÐòµÄλÖã¬ÕâÀïѡĬÈϼ´²½Ö裱´´½¨µÄ¹¤³ÌλÖ㬵ãAdd°´Å¥Íê³ÉÎļþÔÚProjectÖеÄÌí¼Ó¡£
3.³ÌÐòдºÃºó£¬ÏȱàÒëÎļþ£¨Build-> Compile»òctrl+F7£©£¬ÔÙÔËÐУ¨Debug -> Start Without Debugging»òctrl+F5£©£¬¾Í»á¿´µ½Ëùд³ÌÐòµÄÔËÐÐresult£®
¸½£º£±¸ö×î¼òµ¥µÄ£Ã³ÌÐò£¬hoho
first.c
/* ÔÚÆÁÄ»ÉÏÊä³ö×Ö·û´® */
#include <stdio.h>
main()
{
printf("Hello ......

090928ÈÕcÓïÑÔѧϰÈռǣ¨ÎļþI/O)

#include<stdio.h>
#include<stdlib.h>
#define MAX 41
static int i=0;
int main(void)
{
FILE *fp;
char words[MAX];
if((fp=fopen("words","a+"))==NULL)
{
fprintf(stdout,"Can't open \" word\" file\n");
exit(1);
}
puts("Enter words to add to the file,press the enter.");
puts("Key at the begining of a line to terminate.");
while(gets(words)!=NULL&&words[0]!='\0')
{
fprintf(fp,"%s",words);
i++;
}
rewind(fp);
while(fscanf(fp,"%s",words)==1)
{
puts(words);
}
if(fclose(fp)!=0)
{
fprintf(stderr,"Error closing file.\n");
}
return 0;
}

#include<stdio.h>
#include<stdlib.h>
#define MAX 2000
int main(void)
{
FILE *fp;
char words[MAX];
int wordct=0;
if((fp=fopen("words","a+"))==NULL)
{
fprintf(stderr,"Can't open \" word\" file\n");
exit(1);
}
rewind(fp);
while (fgets(words, MAX - 1, fp) != NULL)
wordct++;
rewind(fp);
puts("Enter words to add to the file,press the enter." ......

CÖ¸Õ루1£©

CÓïÑÔ±ØÖª±Ø»á
Ö¸Õ룺
1.Ö¸ÕëÉùÃ÷ºóÒª¸³Öµ£¡·ñÔòÊÇ¿ÕÖ¸Õ룬¿É²»ÖªµÀÖ¸ÏòÁËÄÄÀï
ÀýÈ磺
void swap(int *a,int *b){
    int *tmp;
    *tmp=*a;
    *a=*b;
    *b=*tmp;
}
±¾À´ÊÇÏëÀûÓÃÉÏÃæµÄswapº¯ÊýʵÏÖÁ½¸öÊýµÄ»¥»»£¬µ«ÊÇ*tep=*a;Õâ¾ä»°ÊÇÓÐÎóµÄ£¬ÒòΪָÕëtmpûÓб»¸³Öµ£¡ÊÇÓÃgcc±àÒëʱ²»»á³ö´í£¬µ«ÊÇÔËÐÐʱ»á³öÏֶϴíÎó£¡
2.Êý×éÓëÖ¸Õë
    ÕâÀïÓÐÁ½¸öºÜÈÝÒ×»ìÏýµÄ¸ÅÄÊý×éÖ¸ÕëºÍÖ¸ÕëÊý×é
Ö¸ÕëÖдæ·ÅµÄÊǵØÖ·£¬ËùÒԼȿÉÒÔÖ¸ÏòһάÊý×飬Ҳ¿ÉÒÔÖ¸Ïò¶àάÊý×飬ÏÂÃæÊǼòµ¥µÄÖ¸ÕëºÍÊý×éµÄÀý×Ó¡£
Àý1£º
int data[4];
int *p=data;»òint *p;p=data;
---------------------------------------------------
int data[2][3];
int *p=data;
int i=0;
while(i<2*3){
    scanf("%d",&p[i++]);
}
i=0;
while(i<2*3){
    printf("%d\t",p[i++]);
}
printf("\n");
ÊÇÓÃgcc±àÒëʱ»á²úÉú¾¯¸æ£º´Ó²»¼æÈݵÄÖ¸ÕëÀàÐͳõʼ»¯
    Êý×éÖ¸Õ룬ÕâÀï˵µÄÊý×éÖ¸Õë¼´Ö¸ÏòÊý×éµÄÖ¸Õ룬ÕâÓÐʲôº ......
×ܼǼÊý:2015; ×ÜÒ³Êý:336; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [327] [328] [329] [330] [331] [332] [333] 334 [335] [336]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ