C:Îļþ²Ù×÷ ¶Áд×Ö·ûÓë¶ÁдÐÐ(£¡£¡£¡ºÃ)
À´×Ô£ºhttp://zhangjunhd.blog.51cto.com/113473/100299
1.¶Áд×Ö·ûº¯Êýputc()Óëgetc()
ÕâÁ½¸öº¯ÊýÀàËÆÓÚputchar()Óëgetchar()º¯Êý¡£¼ÙÉèfpÊÇÒ»¸öFILEÖ¸Õ룬chÊÇÒ»¸ö×Ö·û±äÁ¿£¬
ch = getc(fp);// ch = getchar();
putc(ch,fp);// putchar(ch);
½«ÎļþÄÚÈÝ(°´×Ö·û)Êä³öµ½±ê×¼Êä³öµÄCʵÏÖ£º
#include <stdio.h>
#include <stdlib.h>
/* ½«ÎļþÄÚÈÝ(°´×Ö·û)Êä³öµ½±ê×¼Êä³ö */
void read_ch(char * filename, char * mode)
{
int ch;
FILE * fp;
if ((fp = fopen(filename,mode)) == NULL)
{
fprintf(stderr,"Can't open %s.\n",filename);
exit(1);
}
while ((ch = getc(fp)) != EOF)
putc(ch,stdout);
fclose(fp);
}
2.¶ÁдÐк¯Êýfgets()Óëfputs()
gets()º¯ÊýÖ»ÐèÒªÒ»¸ö²ÎÊý(char *)£¬¶øfgets()º¯ÊýÐèÒªÈý¸ö²ÎÊý£¬(char *, int, FILE *)¡£µÚÒ»¸ö²ÎÊýÊÇÓÃÓÚ´æ´¢ÊäÈëµÄµØÖ·£¬µÚ¶þ¸ö²ÎÊý±íʾ×Ö·û´®µÄ×î´ó³¤¶È£¬×îºóÒ»¸ö²ÎÊýÊÇFILEÖ¸Õ롣ͨ³£ÊÇ£º
fgets(buf, MAX, fp)£»//gets(buf);
fgets()º¯Êý¶ÁÈ¡µ½ËüËùÓöµ½µÄµÚÒ»¸ö»»ÐзûµÄºóÃ棬»òÕ߶ÁÈ¡±È×Ö·û´®µÄ×î´ó³¤¶ÈÉÙÒ»¸ö×Ö·û£¬»òÕ߶ÁÈ¡µ½EOF¡£È»ºóËü»áÔÚĩβÌí¼ÓÒ»¸ö'\0'£¬Õâ¾Í¹¹³ÉÁËÒ»¸ö×Ö·û´®¡£(ÕâºÍgets()²»Í¬£¬Ëü»á¶ÁÈ¡µ½'\n'֮ǰ£¬²¢Ìí¼ÓÒ»¸ö'\0'£¬¶øÔٴζÁȡʱ£¬»á¶ªÆú'\n')¡£Óëgets()ÀàËÆ£¬fgets()Óöµ½EOFʱ»á·µ»ØNULL£¬·ñÔò·µ»Ø´«µÝ¸øËüµÄµØÖ·¡£
fputs()º¯Êý½ÓÊÜÁ½¸ö²ÎÊý£¬(char *, FILE *)¡£Óëputs()²»Í¬µÄÊÇ£¬Ëü²»»á×Ô¶¯Ìí¼Ó'\n'¡£Í¨³£ÊÇ£º
fputs(buf, fp);//puts(buf);
½«ÎļþÄÚÈÝ(°´ÐÐ)Êä³öµ½±ê×¼Êä³öµÄCʵÏÖ£º
#include <stdio.h>
#include <stdlib.h>
#define MAXLINE 21
/* ½«Îļ
Ïà¹ØÎĵµ£º
Windows C ¶àÏ̱߳à³ÌµÄ¿âÖ§³Ö
Ïß³ÌʵÖÊÉÏÊdzÌÐòÖеÄÖ´Ðз¾¶¡£Ò²ÊÇ Win32 °²ÅŵÄ×îСִÐе¥Ôª¡£Ḭ̈߳üÀ¨¶ÑÕ»¡¢CPU ¼Ä´æÆ÷µÄ״̬ºÍϵͳ¼Æ»®³ÌÐòÖ´ÐÐÁбíÖеÄÏÿ¸öÏ̹߳²ÏíËùÓнø³ÌµÄ×ÊÔ´¡£
½ø³Ì°üÀ¨Ò»¸ö»ò¶à¸öÏ̺߳ʹúÂë¡¢Êý¾ÝºÍÄÚ´æÖеÄÆäËû³ÌÐò×ÊÔ´¡£µäÐ͵ijÌÐò×ÊÔ´ÊÇ´ò¿ªµÄÎļþ¡¢ÐźŵƺͶ¯Ì¬·ÖÅäµÄÄÚ´æ¡£µ±ÏµÍ³¼Æ» ......
#include <stdio.h>
#include <math.h>
#include <string.h>
int i,j,n,k,b;
float addp;
char bitw[20];
/*³õʼ»¯½á¹¹ÌåÆäÖУºsΪÐÅÔ´·ûºÅ£»pΪÐÅÔ´·ûºÅ¸ÅÂÊ£»paddΪÀÛ¼Ó¸ÅÂÊ£»
l_fΪ-log[p(s[i])]¼´¹À¼ÆÂë×Ö³¤¶È£»lΪʵ¼ÊÐèÒªÂë×Ö³¤¶È£»wΪÂë×Ö*/
struct shan
{char s[20];
&nbs ......
Ç°ÃæһƪÎÒÃǽéÉÜÁËÖ¸Õ룬ÏàÐÅ´ó¼Ò¶ÔÖ¸Õë²»ÔÙÊÇÄÇôİÉú£¬ËäÈ»ÔÚһЩ´óµ¨µÄÖ¸ÕëÇ¿ÖÆÀàÐÍת»»ÉÏÓеĶÁÕß»¹²»Ï°¹ß¡£µ«ÊÇÖÁÉÙ´ó¼ÒÐÄÀïÓиöÊý£¬Ö¸ÕëʽÈç´ËµÄÁé»î£¬ÒÔÖÁÓÚÄã¿ÉÒÔ²Ù×÷µÃ±È½Ïµ×²ã»òÕ߸ù±¾Ô½¹ýһЩÓï·¨µÄÏÞÖÆ¡£Õâ¿ÉÄÜÒ²ÊÇÖÚ¶à³ÌÐòÔ±Åê»÷CC++²»°²È«µÄÒòËØÖ®Ò»¡£°²²»°²È«²»ÊDZ¾ÎÄÏëÒª±í´ïµÄ£¬ÕâÀïÖ»ÐèÒª¼Çסһµã£¬Èç¹û ......
GNU C __attribute__ »úÖƼò½é
2006-06-17 13:54:00
¡¡±êÇ©£º¡¡¡¡¡¡[ÍÆË͵½¼¼ÊõȦ]
ͻ񻣼
ÔÚѧϰlinuxÄں˴úÂ뼰һЩ¿ªÔ´Èí¼þµÄÔ´Â루È磺DirectFB£©£¬¾³£¿ÉÒÔ¿´µ½ÓйØ__attribute__µÄÏà¹ØʹÓᣱ¾ÎĽáºÏ×Ô¼ºµÄѧϰ¾Àú£¬½ÏΪÏêϸµÄ½éÉÜÁË__attribute__Ïà¹ØÓï·¨¼°ÆäʹÓá£
-------------------------------------- ......
³õѧÕ߱ر¸:C ¾µäÈëÃÅÏêϸ½Ì³Ì
¹«ÔªÇ°216Äê8ÔÂ2ÈÕ£¬Òâ´óÀû¶«²¿Æ½Ô£¬Ò»¸ö½Ð×ö¿²ÄáµÄµØ·½£¬Á½Ö§´ó¾ü°Ú¿ªÕóÊÆ£¬×¼±¸¾öÒ»ËÀÕ½¡£Ò»·½ÊÇÓɱ£ÂÞ˹ºÍÍßÂÞÁ½Î»Ö´Õþ¹ÙÂÊÁìµÄÂÞÂíÈË£¬ÁíÒ»·½ÔòÊÇΰ´óµÄ¾üÊÂÌì²ÅººÄá°Î*°Í¿¨ÂÊÁìµÄåÈÌ«»ù¾ü¶Ó¼°ÆäͬÃË¡£ÂÞÂíÈ˳¬¹ý8Íò£¬¶øåÈÌ«»ù½öÓÐ4ÍòÓàÈË¡£È»¶øµ½ÁË°øÍí£¬ÂÞÂíÈ˱»³¹µ×»÷°Ü£¬7ÍòÈ˱» ......