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

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(6)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1.       fcloseº¯Êý
fcloseº¯ÊýµÄ¹¦ÄÜÊǹرÕÒ»¸öÁ÷£¬ÆäÓ÷¨ÊÇ£ºint fclose(FILE *stream); ³ÌÐòÀý×ÓÈçÏ£º
#include <string.h>
#include <stdio.h>
int main(void)
{
   FILE *fp;
   char buf[11] = "0123456789";
   /* create a file containing 10 bytes */
   fp = fopen("DUMMY.FIL", "w");
   fwrite(&buf, strlen(buf), 1, fp);
   /* close the file */
   fclose(fp);
   return 0;
}
2.       fcloseallº¯Êý
fcloseallº¯ÊýµÄ¹¦ÄÜÊǹرմò¿ªÁ÷£¬ÆäÓ÷¨ÊÇ£ºint fcloseall(void); ³ÌÐòÀý×ÓÈçÏ£º
#include <stdio.h>
int main(void)
{
   int streams_closed;
   /* open two streams */
   fopen("DUMMY.ONE", "w");
   fopen("DUMMY.TWO", "w");
   /* close the open streams */
   streams_closed = fcloseall();
   if (streams_closed == EOF)
      /* issue an error message */
      perror("Error");
   else
      /* print result of fcloseall() function */
      printf("%d streams were closed.\n", streams_closed);
   return 0;
}
3.       fcvtº¯Êý
fcvtº¯ÊýµÄ¹¦ÄÜÊÇ°ÑÒ»¸ö¸¡µãÊýת»»Îª×Ö·û´®£¬ÆäÓ÷¨ÊÇ£ºchar *fcvt(double value, int ndigit, int *decpt, int *sign); ³ÌÐòÀý×ÓÈçÏ£º
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   char *string;
   double value;
   int dec, sign;
   int ndig = 10;
   clrscr();
   value = 9.876;
   string = ecvt(value, ndig, &dec, &sign);
   printf("string = %s     


Ïà¹ØÎĵµ£º

CÌâÄ¿3

1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR   (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
     1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
     2). ¶®µÃÔ¤´¦ÀíÆ÷½«Î ......

C/C++ ³£¼ûÃæÊÔÌâ

 
1.Ö¸ÕëºÍÒýÓÃÓÐʲô·Ö±ð£»Èç¹û´«ÒýÓñȴ«Ö¸Õ밲ȫ£¬ÎªÊ²Ã´£¿Èç¹ûÎÒʹÓó£Á¿Ö¸ÕëÄѵÀ²»ÐÐÂð£¿
     (1) ÒýÓÃÔÚ´´½¨µÄͬʱ±ØÐë³õʼ»¯£¬¼´ÒýÓõ½Ò»¸öÓÐЧµÄ¶ÔÏ󣻶øÖ¸ÕëÔÚ¶¨ÒåµÄʱºò²»±Ø³õʼ»¯£¬¿ÉÒÔÔÚ¶¨ÒåºóÃæµÄÈκεط½ÖØи³Öµ£®
     (2) ²»´æÔڣΣգ̣ÌÒýÓã¬ÒýÓÃ±Ø ......

CºÍC£«£«»ìºÏ±à³ÌÏà¹ØÎÊÌâ½â¾ö·½·¨

Ò» £º½â¾öC»òC++ÖеÄmultiple definition ofÎÊÌâ
server.cpp
clientp2p.cpp
#include "exception.h"
#include "clientp2p.h"
clientp2p.h
ÖÐдÓÐËùÓеÄÈ«¾Ö±äÁ¿¼°Æä³õʼ»¯Öµ
ºÍº¯ÊýÉùÃ÷
1.server.cppÖУº
ÒýÓÃ
£º
#include "clientp2p.h"
int Main(....)
{
...
}
2.clientp ......

C++ÖÐextern ¡°C¡±º¬ÒåÉî²ã̽Ë÷

(ת)C++ÖÐextern “C”º¬ÒåÉî²ã̽Ë÷
 
 
1.ÒýÑÔ
¡¡¡¡C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏó&rdquo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ