×î½üÔÚÍøÉϲéÁ˺öà¹ØÓÚC²¥·ÅwavÕâ·½ÃæµÄ×ÊÁÏ£¬µ÷ÊÔ°ëÌìҲûÓнá¹û£¬Ëѵ½Ò»¸ö±àÒëºÃµÄEXEÎļþÄܲ¥·Å£¬Ã»ÓÐÔ´´úÂ룬·´»ã±à²»ÁË£¬ËÄÜÖ¸µãһϡ£¡£¡£¡£¡£ÒÔÏÂÁ½ÖÖ´úÂë¶Î£º
#include <stdio.h>
#include <dos.h>
/* wavÎļþ½á¹¹ */
typedef struct WaveData
{
unsigned long sample_lenth;
unsigned short rate;
unsigned short channels;
unsigned char time_constant;
char bit_res;
char *name_wav;
char *sample;
} WAV;
/* wavÍ·ÐÅÏ¢½á¹¹ */
typedef struct HeaderType
{
long riff; /*RIFFÀà×ÊÔ´ÎļþÍ·²¿*/
unsigned long file_len; /*Îļþ³¤¶È*/
char &n ......
ÔÚÌÖÂÛÈ«¾Ö±äÁ¿Ö®Ç°ÎÒÃÇÏÈÒªÃ÷°×¼¸¸ö»ù±¾µÄ¸ÅÄ
1. ±àÒëµ¥Ôª(Ä£¿é)£º
ÔÚIDE¿ª·¢¹¤¾ß´óÐÐÆäµÀµÄ½ñÌ죬¶ÔÓÚ±àÒëµÄһЩ¸ÅÄîºÜ¶àÈËÒѾ²»ÔÙÇå³þÁË£¬ºÜ¶à³ÌÐòÔ±×îŵľÍÊÇ´¦ÀíÁ¬½Ó´íÎó(LINK ERROR), ÒòΪËü²»Ïñ±àÒë´íÎóÄÇÑù¿ÉÒÔ¸ø³öÄã³ÌÐò´íÎóµÄ¾ßÌåλÖã¬Äã³£³£¶ÔÕâÖÖ´íÎó¸Ðµ½°ÃÄÕ£¬µ«ÊÇÈç¹ûÄã¾³£Ê¹ÓÃgcc£¬makefileµÈ¹¤¾ßÔÚlinux»òÕßǶÈëʽÏÂ×ö¿ª·¢¹¤×÷µÄ»°£¬ÄÇôÄã¿ÉÄܷdz£µÄÀí½â±àÒëÓëÁ¬½ÓµÄÇø±ð£¡µ±ÔÚVCÕâÑùµÄ¿ª·¢¹¤¾ßÉϱàдÍê´úÂ룬µã»÷±àÒë°´Å¥×¼±¸Éú³ÉexeÎļþʱ£¬VCÆäʵ×öÁËÁ½²½¹¤×÷£¬µÚÒ»²½£¬½«Ã¿¸ö.cpp(.c)ºÍÏàÓ¦.hÎļþ±àÒë³ÉobjÎļþ£»µÚ¶þ²½£¬½«¹¤³ÌÖÐËùÓеÄobjÎļþ½øÐÐLINKÉú³É×îÖÕµÄ.exeÎļþ£¬ÄÇô´íÎó¾ÍÓпÉÄÜÔÚÁ½¸öµØ·½²úÉú£¬Ò»¸öÊDZàÒëʱµÄ´íÎó£¬Õâ¸öÖ÷ÒªÊÇÓï·¨´íÎó£¬ÁíÒ»¸öÊÇÁ¬½Ó´íÎó£¬Ö÷ÒªÊÇÖظ´¶¨Òå±äÁ¿µÈ¡£ÎÒÃÇËù˵µÄ±àÒëµ¥Ôª¾ÍÊÇÖ¸ÔÚ±àÒë½×¶ÎÉú³ÉµÄÿ¸öobjÎļþ£¬Ò»¸öobjÎļþ¾ÍÊÇÒ»¸ö±àÒëµ¥Ôª£¬Ò²¾ÍÊÇ˵һ¸öcpp(.c)ºÍËüÏàÓ¦µÄ.hÎļþ¹²Í¬×é³ÉÁËÒ»¸ö±àÒëµ¥Ôª£¬Ò»¸ö¹¤³ÌÓɺܶà¸ö±àÒëµ¥Ôª×é³É£¬Ã¿¸öobjÎļþÀï°üº¬Á˱äÁ¿´æ´¢µÄÏà¶ÔµØÖ·µÈ ¡£
2. ÉùÃ÷Ó붨ÒåµÄÇø±ð
º¯Êý»ò±äÁ¿ÔÚÉùÃ÷ʱ£¬²¢Ã»ÓиøËüʵ¼Êµ ......
ÔÚÌÖÂÛÈ«¾Ö±äÁ¿Ö®Ç°ÎÒÃÇÏÈÒªÃ÷°×¼¸¸ö»ù±¾µÄ¸ÅÄ
1. ±àÒëµ¥Ôª(Ä£¿é)£º
ÔÚIDE¿ª·¢¹¤¾ß´óÐÐÆäµÀµÄ½ñÌ죬¶ÔÓÚ±àÒëµÄһЩ¸ÅÄîºÜ¶àÈËÒѾ²»ÔÙÇå³þÁË£¬ºÜ¶à³ÌÐòÔ±×îŵľÍÊÇ´¦ÀíÁ¬½Ó´íÎó(LINK ERROR), ÒòΪËü²»Ïñ±àÒë´íÎóÄÇÑù¿ÉÒÔ¸ø³öÄã³ÌÐò´íÎóµÄ¾ßÌåλÖã¬Äã³£³£¶ÔÕâÖÖ´íÎó¸Ðµ½°ÃÄÕ£¬µ«ÊÇÈç¹ûÄã¾³£Ê¹ÓÃgcc£¬makefileµÈ¹¤¾ßÔÚlinux»òÕßǶÈëʽÏÂ×ö¿ª·¢¹¤×÷µÄ»°£¬ÄÇôÄã¿ÉÄܷdz£µÄÀí½â±àÒëÓëÁ¬½ÓµÄÇø±ð£¡µ±ÔÚVCÕâÑùµÄ¿ª·¢¹¤¾ßÉϱàдÍê´úÂ룬µã»÷±àÒë°´Å¥×¼±¸Éú³ÉexeÎļþʱ£¬VCÆäʵ×öÁËÁ½²½¹¤×÷£¬µÚÒ»²½£¬½«Ã¿¸ö.cpp(.c)ºÍÏàÓ¦.hÎļþ±àÒë³ÉobjÎļþ£»µÚ¶þ²½£¬½«¹¤³ÌÖÐËùÓеÄobjÎļþ½øÐÐLINKÉú³É×îÖÕµÄ.exeÎļþ£¬ÄÇô´íÎó¾ÍÓпÉÄÜÔÚÁ½¸öµØ·½²úÉú£¬Ò»¸öÊDZàÒëʱµÄ´íÎó£¬Õâ¸öÖ÷ÒªÊÇÓï·¨´íÎó£¬ÁíÒ»¸öÊÇÁ¬½Ó´íÎó£¬Ö÷ÒªÊÇÖظ´¶¨Òå±äÁ¿µÈ¡£ÎÒÃÇËù˵µÄ±àÒëµ¥Ôª¾ÍÊÇÖ¸ÔÚ±àÒë½×¶ÎÉú³ÉµÄÿ¸öobjÎļþ£¬Ò»¸öobjÎļþ¾ÍÊÇÒ»¸ö±àÒëµ¥Ôª£¬Ò²¾ÍÊÇ˵һ¸öcpp(.c)ºÍËüÏàÓ¦µÄ.hÎļþ¹²Í¬×é³ÉÁËÒ»¸ö±àÒëµ¥Ôª£¬Ò»¸ö¹¤³ÌÓɺܶà¸ö±àÒëµ¥Ôª×é³É£¬Ã¿¸öobjÎļþÀï°üº¬Á˱äÁ¿´æ´¢µÄÏà¶ÔµØÖ·µÈ ¡£
2. ÉùÃ÷Ó붨ÒåµÄÇø±ð
º¯Êý»ò±äÁ¿ÔÚÉùÃ÷ʱ£¬²¢Ã»ÓиøËüʵ¼Êµ ......
Õ»£ºº¯Êýµ÷ÓõÄʱºò£¬ÔÚÕ»Öб£´æ¾Ö²¿±äÁ¿ºÍº¯Êý²ÎÊýµÈ¡£µ±º¯Êý·µ»Øʱ£¬×Ô¶¯Çå³ýÕ»¡£
×ÔÓÉ´æ´¢Çø£ºÒ²³ÆΪ¶Ñ(heap)£¬¿ÉÒÔ¿´×÷´óÁ¿µÄÄÚ´æ¶Î¡£Í¨¹ý new ²Ù×÷·û·ÖÅäµÄÄÚ´æÔÚ¶ÑÖС£³ÌÐò½áÊø֮ǰ²»×Ô¶¯Çå³ý×ÔÓÉ´æ´¢Çø¡£ÐèÒªÓɳÌÐòÀ´¸ºÔðÊÍ·Å£¨delete£©¡£
1.
¶ÔÖ¸ÏòÕ»ÉÏÄÚ´æµÄÖ¸Õëµ÷ÓÃdelete»áµ¼Ö³ÌÐòCrash¡£
2.
new ½øÐÐ×ÔÓÉ´æ´¢ÇøÖÐÄÚ´æ·ÖÅä¡£
Èç¹û new ²»ÄÜÔÚ×ÔÓÉ´æ´¢ÇøÖд´½¨Äڴ棬Ôò»á·µ»Ø NULLÖ¸Õ롣ÿ´Î·ÖÅäÐÂÄÚ´æʱһ¶¨Òª¼ì²éÖ¸ÕëÊÇ·ñΪ null.
delete ²Ù×÷ʵ¼ÊÉÏÊǻָ´Ö¸ÕëËùÖ¸µÄÄڴ棬ʹ֮¿ÉÒÔÔÙÓ㬶ø²»ÖÁÓÚÔì³ÉÄÚ´æй©(memory leak).
¶øÖ¸ÕëÈÔÈ»ÊÇÖ¸Õ룬±ØҪʱ»¹¿ÉÒÔÖØи³Öµ¡£
Èç¹û¶ÔÒѾÊͷŹýµÄÖ¸Õëµ÷Óà delete ²Ù×÷£¬»áµ¼Ö³ÌÐò±ÀÀ£¡£µ±É¾³ýÖ¸Õëʱ£¬¸øÖ¸Õ븳ֵ NULL(0), ¶Ô¿ÕÖ¸Õëµ÷Óà delete ÊÇ°²È«µÄ¡£
ÄÚ´æй©£ºÒ»ÖÖÇé¿öÊdzÌÐòÔÚδÊÍ·ÅËüÖ¸ÏòµÄÄÚ´æ֮ǰ¾Í¸øÖ¸ÕëÖØи³Öµ¡£
µ±³ÌÐò¶Ô×ÔÓÉ´æ´¢ÇøÖеĶÔÏóÖ¸Õëµ÷Óà delete ʱ£¬ÔÚÊÍ·ÅÄÚ´æ֮ǰ»á×Ô¶¯µ÷ÓöÔÏóµÄÎö¹¹º¯Êý¡£Õâ¸ö²ßÂÔ¸øÀàÌṩÁËÇåÀíµÄ»ú»á¡£
3.
¶ÔÓÚSymbianÓ¦ÓóÌÐò£¬Èç¹ûÏÈdeleteÁËÒ»¸öÖ¸ÕëÖ¸ÏòµÄÄڴ棬µ«Ã»ÓаÑÕâ¸öÖ¸Õ븳ֵΪNULL£¬È»ºóÔÚij´¦·¢ÉúÁËLeave, Çå³ýÕ»µ¯³öÖ¸Õë²¢ÔÙ´Îdelet ......
Õ»£ºº¯Êýµ÷ÓõÄʱºò£¬ÔÚÕ»Öб£´æ¾Ö²¿±äÁ¿ºÍº¯Êý²ÎÊýµÈ¡£µ±º¯Êý·µ»Øʱ£¬×Ô¶¯Çå³ýÕ»¡£
×ÔÓÉ´æ´¢Çø£ºÒ²³ÆΪ¶Ñ(heap)£¬¿ÉÒÔ¿´×÷´óÁ¿µÄÄÚ´æ¶Î¡£Í¨¹ý new ²Ù×÷·û·ÖÅäµÄÄÚ´æÔÚ¶ÑÖС£³ÌÐò½áÊø֮ǰ²»×Ô¶¯Çå³ý×ÔÓÉ´æ´¢Çø¡£ÐèÒªÓɳÌÐòÀ´¸ºÔðÊÍ·Å£¨delete£©¡£
1.
¶ÔÖ¸ÏòÕ»ÉÏÄÚ´æµÄÖ¸Õëµ÷ÓÃdelete»áµ¼Ö³ÌÐòCrash¡£
2.
new ½øÐÐ×ÔÓÉ´æ´¢ÇøÖÐÄÚ´æ·ÖÅä¡£
Èç¹û new ²»ÄÜÔÚ×ÔÓÉ´æ´¢ÇøÖд´½¨Äڴ棬Ôò»á·µ»Ø NULLÖ¸Õ롣ÿ´Î·ÖÅäÐÂÄÚ´æʱһ¶¨Òª¼ì²éÖ¸ÕëÊÇ·ñΪ null.
delete ²Ù×÷ʵ¼ÊÉÏÊǻָ´Ö¸ÕëËùÖ¸µÄÄڴ棬ʹ֮¿ÉÒÔÔÙÓ㬶ø²»ÖÁÓÚÔì³ÉÄÚ´æй©(memory leak).
¶øÖ¸ÕëÈÔÈ»ÊÇÖ¸Õ룬±ØҪʱ»¹¿ÉÒÔÖØи³Öµ¡£
Èç¹û¶ÔÒѾÊͷŹýµÄÖ¸Õëµ÷Óà delete ²Ù×÷£¬»áµ¼Ö³ÌÐò±ÀÀ£¡£µ±É¾³ýÖ¸Õëʱ£¬¸øÖ¸Õ븳ֵ NULL(0), ¶Ô¿ÕÖ¸Õëµ÷Óà delete ÊÇ°²È«µÄ¡£
ÄÚ´æй©£ºÒ»ÖÖÇé¿öÊdzÌÐòÔÚδÊÍ·ÅËüÖ¸ÏòµÄÄÚ´æ֮ǰ¾Í¸øÖ¸ÕëÖØи³Öµ¡£
µ±³ÌÐò¶Ô×ÔÓÉ´æ´¢ÇøÖеĶÔÏóÖ¸Õëµ÷Óà delete ʱ£¬ÔÚÊÍ·ÅÄÚ´æ֮ǰ»á×Ô¶¯µ÷ÓöÔÏóµÄÎö¹¹º¯Êý¡£Õâ¸ö²ßÂÔ¸øÀàÌṩÁËÇåÀíµÄ»ú»á¡£
3.
¶ÔÓÚSymbianÓ¦ÓóÌÐò£¬Èç¹ûÏÈdeleteÁËÒ»¸öÖ¸ÕëÖ¸ÏòµÄÄڴ棬µ«Ã»ÓаÑÕâ¸öÖ¸Õ븳ֵΪNULL£¬È»ºóÔÚij´¦·¢ÉúÁËLeave, Çå³ýÕ»µ¯³öÖ¸Õë²¢ÔÙ´Îdelet ......
#include "stdio.h"
#include "math.h"
#include "time.h"
#define INTERVAL 1 ¶¨ÒåºêµÄʱ¼ä¼ä¸ôΪ1Ãë
//
void On_Time() //ÿһÃ뼤·¢µÄʼþ
{
printf("now=%s\n","JJK");
}
void Timer() //ʱÖӵĺ¯Êý
{ time_t newclk,oldclk;
while(1)
{
time(&newclk);
if(abs(difftime(newclk,oldclk))>=INTERVAL)
{
On_Time();
}
oldclk=newclk;
}
}
int main() //Ö÷º¯Êý
{
Timer();
} ......
#include "stdio.h"
#include "math.h"
#include "time.h"
#define INTERVAL 1 ¶¨ÒåºêµÄʱ¼ä¼ä¸ôΪ1Ãë
//
void On_Time() //ÿһÃ뼤·¢µÄʼþ
{
printf("now=%s\n","JJK");
}
void Timer() //ʱÖӵĺ¯Êý
{ time_t newclk,oldclk;
while(1)
{
time(&newclk);
if(abs(difftime(newclk,oldclk))>=INTERVAL)
{
On_Time();
}
oldclk=newclk;
}
}
int main() //Ö÷º¯Êý
{
Timer();
} ......
http://blog.csdn.net/Ackarlix/archive/2007/08/25/1758412.aspx
WindowsÏÂCÍøÂç±à³ÌÈëÃÅ
CÓïÑÔµÄѧϰ£¬Ò»°ãµÄ·½Ê½ÊÇ£¬ÏÈѧC£¬È»ºóÊÇC++£¬×îºÃ»¹ÒªÓлã±àÓïÑÔºÍ΢»úÔÀí»ù´¡£¬È»ºó²ÅÊÇVisual C++¡£ÕâÑùµÄ·½Ê½£¬¶ÔѧϰÕßÀ´Ëµ£¬Òª»¨·ÑºÜ¶àʱ¼äºÍÄÍÁ¦¡£¶øÔÚѧУ½ÌѧÖУ¬Ò²Ã»ÓÐʱ¼äÉîÈëѧϰWindows±à³ÌµÄʵÓü¼ÊõÁË¡£
¡¡¡¡ Æäʵ£¬¾ßÓÐÁËCÓïÑÔ»ù´¡ºó£¬ÔÙÓÐһЩ»ù±¾µÄC++ÀàµÄ¸ÅÄ¾Í¿ÉÒÔÖ±½ÓѧϰWindows C±à³ÌÁË¡£
¡¡¡¡ Ò»¡¢×ß½üWindows CÓïÑÔ
¡¡¡¡ ºÜ¶àÓïÑÔ¶¼°ÑÏÔʾһ¸ö“Hello,World!”×öΪµÚÒ»¸öÈëÃųÌÐò£¬ CÓïÑԵĵÚÒ»¸ö³ÌÐòÊÇÕâÑùµÄ£º
#include<stdio.h>
main()
{
¡¡ printf(“Hello,World!”);
}
¡¡¡¡ Èç¹û°Ñmainº¯Êýд³É´ø²ÎÊýµÄmainº¯Êý£¬Ó¦¸ÃÊÇ£º
#include<stdio.h>
main(int arge,char *argv[])
{
¡¡ printf(“Hello,World!”);
}
¡¡¡¡ Windows CµÄµÚÒ»¸ö³ÌÐòºÍÕâ¸ö³ÌÐòÔÚÐÎʽºÍÔÀíÉ϶¼ÊÇÒ»Öµģ¬Ö»ÊÇÓÐÁ½µã²»Í¬£º
¡¡¡¡ 1. Ö÷º¯Êý½ÓÊÕµÄÐββ»Ö»ÊÇÃüÁîÐÐÖеÄ×Ö·û´®µÄ¸öÊýºÍ×Ö·û´®µÄÊ×µØÖ·¡£
¡¡
¡¡ 2. CÓïÑԵĺܶຯÊýÔÚWindows
CÖж¼¿ÉÒÔ¼ÌÐøʹÓ㬵«Ïóprintf£¨£©ÆÁÄ»ÏÔʾµÈº¯Êý¾Í²»ÄܼÌÐøʹÓÃÁË¡£ÒòÎ ......
ÐÂÈ˸տªÊ¼Íæ×îºÃ½¨¸öÃâ·ÑºÅÏÈÊìϤÏÂÓÎÏ·£¬ÏÈ°ÑÐÂÊֽ̳Ì×öÍ棬½Ì³ÌÒªÂýÂý×ö£¬°Ñÿһ²½½ÌµÄ¶¼Ñ§µ½¡£ÎÒÇ¿ÁÒBS×öÍê½Ì³Ì»¹²»»áÍê˵½Ì³Ì²»ºÃµÄÈË£¬ÒÔÇ°ÎÒÍêÅ··þ¶¼ÊÇ×öÍê½Ì³Ì¾ÍÄÜ¿ªÊ¼ÍêÁË£¬ÎÒ»¹ÊÇÓõĽðɽ¿ìÒë2002µÄ£¬¸Â¸Â¡£
ÑÔ¹éÕý´«£¬ÐÂÈË×öÍê½Ì³Ì×îºóµÄ2¸öÈÎÎñÊÖÉϸÃÓÐ10W¶àÁË£¨×îºóµÄÄǸö´úÀíÈËÈÎÎñ²»×ö½Ì³ÌÒ²¿ÉÒÔÖ±½Ó×ö£©£¬Õâ¸öʱºòÂòÉÏÒ»ÌõͺðÕ£¬ÂòÉÏ2¸ö125µÄÅھͿÉÒÔÈ¥½ÓÒ»¼¶ µÄ´úÀíÈËÈÎÎñÁË£¬ÕâÀïҪעÒâµÄÊÇ×Óµ¯×îºÃÂòÌúµÄ£¬ÎҼǵÃÕâÑùÄÜ´ò16KM¶ø1¼¶´úÀíÈ˵ÄÈÎÎñµÄ¹Ö»ù±¾É϶¼Ö»ÄÜ´ò10KMËùÒÔ±£³ÖºÃ¾àÀë´òÆðÀ´ºÜ¼òµ¥µÄ£¬µÈ×öÁ˼¸´ÎÓÐÇ®Á˾ÍÂòµ¼µ¯µÄÊ飬Ȼºóѧµ¼µ¯¡£¼ÌÐøË¢¹Ö£¬µÈÇ®¹»Á˾ÍÂò²èöÀ¿ª£¬È»ºó¼ÌÐøË¢¹Ö£¬¿ª²èҪעÒâºÍµÐÈ˱£³Ö¾àÀ룬»¹ÓоÍÊÇ´ò¹Ö²»ÒªÒýÌ«¶à£¬Ö÷ÒªÕâ¸öʱºòÒ»°ãɾ¸ñ²»¹»£¬Ö»ÄÜÓÃÃñÓüÓÁ¦ËÙ¶ÈÂý£¬²»ÐоÍÅÜ£¡½ÓÏÂÀ´ÄãÈç¹û¶ÔÓÎÏ·ÊìϤµÄ»°¿ÉÒÔÂò¸öСӥˢËÀÍö¿Õ¼ä£¬²»È»µÄ»°»¹ÊÇË¢ÈÎÎñ£¬Ò»Ö±Ë¢µ½600W Eve Isk¡£½ÓÏÂÀ´ÄãÈç¹ûϲ»¶Õ½¶·¿ÉÒÔÂò¸öÅ¡»¶¼Ó¸ö¾üÍÅÈ¥0.0×éÈËɱ¹Ö´òÇ®£¬»òÕßÒ»¸öÈËÔÚ0.1µ½0.3Ë¢Eve Isk¡£²»Ï²»¶µÄ¿ÉÒÔÂò¸ö¹¤Òµ×öóÒס£
±¾ÈËÍƼö¼Ó¾üÍÅ´òÇ®£¬À´Ç®±È½Ï¿ì¡£¾ÍÊÇÔÚ¾üÍŵÄ0.0µØÇø¼ñÀ¬»ø£¬Ò»Ð¡Ê±¼ñµÄÀ¬»øÄÜÓÐ500W-1000W¡£À´Ç®±È½Ï¿ì£¬¶øÇÒÄܼñµ ......