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

¿¼²éǶÈëʽC¿ª·¢ÈËÔ±×îºÃµÄÊ®µÀÌâ²Î¿¼´ð°¸

Ïêϸ²Î¿¼´ð°¸
µÚ1Ìâ:   (b)
volatile×ÖÃæÒâ˼ÊÇÒ×ÓÚ»Ó·¢µÄ¡£Õâ¸ö¹Ø¼ü×ÖÀ´ÃèÊöÒ»¸ö±äÁ¿Ê±£¬Òâζ×Å ¸ø¸Ã±äÁ¿¸³Öµ(дÈë)Ö®ºó£¬ÂíÉÏÔÙ¶ÁÈ¡£¬Ð´ÈëµÄÖµÓë¶ÁÈ¡µÄÖµ¿ÉÄܲ»Ò»Ñù,ËùÒÔ˵Ëü"ÈÝÒ×»Ó·¢"µÄ¡£
ÕâÊÇÒòΪÕâ¸ö±äÁ¿¿ÉÄÜÒ»¸ö¼Ä´æÆ÷£¬Ö±½ÓÓëÍⲿÉ豸ÏàÁ¬£¬ÄãдÈëÖ®ºó£¬¸Ã¼Ä´æÆ÷Ò²ÓпÉÄܱ»ÍⲿÉ豸µÄд²Ù×÷Ëù¸Ä±ä;»òÕߣ¬¸Ã±äÁ¿±»Ò»¸öÖжϳÌÐò£¬»òÁíÒ»¸ö½ø³Ì
¸Ä±äÁË.
volatile ²»»á±»±àÒëÆ÷ÓÅ»¯Ó°Ï죬ÔÚlongjump ºó,ËüµÄÖµ ÊǺóÃæ¼Ù¶¨µÄ±äÁ¿Öµ,b×îºóµÄÖµÊÇ5,ËùÒÔ5±»´òÓ¡³öÀ´.
setjmp : ÉèÖ÷Ǿֲ¿Ìøת /* setjmp.h*/
Stores context information such as register values so that the lomgjmp function can return control to the statement following the one calling setjmp.Returns 0 when it is initially called.
Lonjjmp: Ö´ÐÐÒ»¸ö·Ç¾Ö²¿Ìøת /* setjmp.h*/
Transfers control to the statement where the call to setjmp (which initialized buf) was made. Execution continues at this point as if longjmp cannot return the value 0.A nonvolatile automatic variable might be changed by a call to longjmp.When you use setjmp and longjmp, the only automatic variables guaranteed to remain valid are those declared volatile.
Note: Test program without volatile qualifier (result may very)
¸üÏêϸ½éÉÜ£¬Çë²ÎÔÄ CÓïÑÔµÄsetjmpºÍlongjmp
µÚ2Ìâ:   (a)
½á¹¹ÌâµÄ³ÉÔ±ÔÚÄÚ´æÖеĵØÖ·ÊÇ°´ÕÕËûÃǶ¨ÒåµÄλÖÃ˳ÐòÒÀ´ÎÔö³¤µÄ¡£Èç¹ûÒ»¸ö½á¹¹ÌåµÄÖ¸Õë±»¿´³É ËüµÄµÚÒ»¸ö³ÉÔ±µÄÖ¸Õë,ÄÇô¸ÃÖ¸ÕëµÄÈ·Ö¸ÏòµÚÒ»¸ö³ÉÔ±
µÚ3Ìâ:  (a)
´ËÌâÄ¿½ÏÄÑ.
Õâ¸ö³ÌÐòµÄ·ÇµÝ¹é°æ±¾
int  what ( int x , int  n)
{
  int val;
  int product;
  product =1;
  val =x;
  while(n>0)
  {
     if (n%2 == 1)
       product = product*val;   /*Èç¹ûÊÇÆæÊý´ÎÃÝ,  x(val)ÒªÏȳËÉÏÒ»´Î,;  żÊý´ÎÃÝ,×îºó·µ»Øʱ²Å»áµ½ÕâÀï³ËÒÔ1*/
     val = val* val;
     n = n/2;
   }
   return product;
}/* ÓöþÔª¸´³Ë²ßÂÔ */
Ëã·¨ÃèÊö
(while n>0)
{
  if  next most significant binary digit of  n( power)&n


Ïà¹ØÎĵµ£º

´Óprintf()̸c/c++Öпɱä²ÎÊýº¯ÊýµÄʵÏÖ


´Óprintf̸¿É±ä²ÎÊýº¯ÊýµÄʵÏÖ ×ªÌù
Ô­ÎÄ×÷ÕߣºÈÖÑÇÐÂ
ÕªÒª£ºÒ»Ö±ÒÔÀ´¶¼¾õµÃprintfËƺõÊÇcÓïÑÔ¿âÖй¦ÄÜ×îÇ¿´óµÄº¯ÊýÖ®Ò»£¬²»½öÒòΪËüÄܸñʽ»¯Êä³ö£¬¸üÔÚÓÚËüµÄ²ÎÊý¸öÊýûÓÐÏÞÖÆ£¬Òª¼¸¸ö¾Í¸ø¼¸¸ö£¬À´Õß²»¾Ü¡£printfÕâÖÖ¶Ô²ÎÊý¸öÊýºÍ²ÎÊýÀàÐ͵ÄÇ¿´óÊÊÓ¦ÐÔ£¬ÈÃÈ˲úÉúÁ˶ÔËü½øÐÐ̽Ë÷µÄŨºñÐËȤ¡£
¹Ø¼ü×Ö£ºprintf, ¿É±ä²ÎÊ ......

MISRA ×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶

MISRA--×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶(ǶÈëʽc¿ª·¢Õ߱ضÁ)
 
MISRA--×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶
 
  MISRA (The Motor Industry Software Reliability Association
Æû³µ¹¤ÒµÈí¼þ¿É¿¿ÐÔÁª»á)
ÊÇλÓÚÓ¢¹úµÄÒ»¸ö¿ç¹úÆû³µ¹¤ÒµÐ­»á£¬Æä³ÉÔ±°üÀ¨Á˴󲿷ÖÅ·ÃÀÆû³µÉú²úÉÌ¡£ÆäºËÐÄʹÃüÊÇΪÆû³µ¹¤ÒµÌṩ·þÎñºÍЭÖú£¬°ïÖ ......

c»ñÈ¡ÎļþµÄ´óСºÍÎļþÊôÐÔ¡¢Îļþ²éÕÒ

1 fseekÒƶ¯Ö¸Õë»ñÈ¡
#include <stdio.h>
#include <stdlib.h>
long filesize( FILE *fp )
{
    long int save_pos;
    long size_of_file;
    /* Save the current position. */
    save_pos = ftell( fp );
    /* ......

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

1.ÒýÑÔ
¡¡¡¡C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ºÍº¯Êý¡£µ«ÊÇ£¬C++±Ï¾ ......

¿¼²éǶÈëʽC¿ª·¢ÈËÔ±×îºÃµÄÊ®µÀÌâ

·Ç³£»ù±¾¹ØÓÚCÓïÑÔµÄÎÊÌâ,Ò»¸öÐÅÏ¢Àà(¼ÆËã»ú,×ÊѶ¹¤³Ì,µç×Ó¹¤³Ì, ͨÐŹ¤³Ì)רҵµÄ±¾¿Æ±ÏÒµÉúÓ¦¸Ã´ïµ½µÄˮƽ¡£ÌâÄ¿²»ÄÑ,È«²¿¶¼ÄÜ¿ìËٵشðÍ꣬µ±È»Ò²ÐèÒªÒ»¶¨µÄ֪ʶ´¢±¸¡£
¶ÔÓÚ´ó¶àÊýÈË£¬ÎÒÃÇÔ¤ÆÚÄã¿ÉÄÜ´ð´í 3)   4)  15)Ì⣬ËùÒÔ´ð´í3µÀÒÔÄڵģ¬ÎÒÃÇÈÏΪÄãºÜ°ô
´ð´í5µÀÌâÒÔÄÚ£¬ÎÒÃÇÈÏΪÄ㻹²»´í(Ä㻹¿ÉÄÜ´ð ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ