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

C·¢Éù³ÌÐò

#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <conio.h>
typedef struct {
      short int pitch;
      short int duration;
} NOTE;
NOTE notes[] = {{14, 500}, {16, 500}, {12, 500}, {0, 500}, {7, 1000}};
void setfreq(int hz)
{
       hz = 1193180 / hz;      // clocked at 1.19MHz
       _outp(0x43, 0xb6);      // timer 2, square wave
       _outp(0x42, hz);
       _outp(0x42, hz >> 8);
}
void playnote(NOTE note)
{
      _outp(0x61, _inp(0x61) | 0x03);   // start speaker going
      setfreq((int)(400 * pow(2, note.pitch / 12.0)));
      Sleep(note.duration);
      _outp(0x61, _inp(0x61) & ~0x03);  // stop that racket!
}
int main(int argc, char* argv[])
{
     int i;
     HANDLE h;
     h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL,
     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     if(h == INVALID_HANDLE_VALUE)
     {
           printf("Couldn't access giveio device\n");
           return -1;
     }
     for(i=0; i < sizeof(notes)/sizeof(int); ++i)
           playnote(notes[i]);
     CloseHandle(h);
     return 0;
}
Óм¸µãÐèҪעÒ⣺
1£¬\\\\.\\giveioÊÇ´ò¿ªµÄÉ豸£¬ÓÉÓÚÊÇÓÃ\\תÒå±íʾ\£¬ËùÒÔÉÏÊöÆäʵÊDZíʾ\\ . \
2£¬ÕâÖֵײãµÄ±à³ÌºÜÉÙ¡£ÒÔÉÏ_outp·ÃÎʵÄÊǵײã¼Ä´æÆ÷£¬¹¦ÄÜÈç×¢


Ïà¹ØÎĵµ£º

turbo C ϵĴò×ÖÓÎÏ·

ÔÚÕâÀïÌùÉÏ×î½ü×Ô¼ºÃ¦»îµÄÓÃturbo C±àдµÄ“´ò×ÖÓÎÏ·”µÄÔ´´úÂ룺
#include<graphics.h>
#include<conio.h>
#include<STDLIB.h>
#include<dos.h>
#define BK_COLOR BLACK
#define CHAR_COLOR WHITE
#define C_COLOR BLUE
#define num 10
#define SPEED 3000
#define Esc 27
# ......

¿É±äÄ¿±êC±àÒëÆ÷ µÚ4Õ ÀàÐÍ

C³ÌÐòÖоßÓзḻµÄÊý¾ÝÀàÐÍ£¬°üÀ¨ÉùÃ÷ÖÐÏÔʽ¶¨ÒåµÄÀàÐͺÍÓÃ×ö±í´ïʽÖмäÀàÐ͵ĵ¼³öÀàÐÍ¡£ÀýÈ磬ÏÂÃæµÄ¸³ÖµÓï¾ä°üº¬3 ÖÖ²»Í¬ÀàÐÍ:
    int *p, x;
    *p = x;
xÊÇÒ»¸ö´æ·ÅÕûÊýµÄµ¥ÔªµÄµØÖ·£¬Òò´ËxµÄµØÖ·µÄÀàÐÍÊÇ£ºÖ¸ÏòÒ»¸öÕûÊýµÄÖ¸Õë¡£xµÄÖµµÄÀàÐÍÊÇÕûÐÍ¡£Í¬Ñù, pµÄ×óÖµµÄÀàÐÍÊÇÖ¸ÏòÒ»¸öÕ ......

CÓëC++·ç¸ñ×Ö·û´®

C·ç¸ñ×Ö·û´®£º¶Ô×Ö·û´®½øÐвÙ×÷µÄ C º¯Êý¶¨ÒåÔÚÍ·Îļþ<cstring>ÖУ»
     1. ×Ö·û´®¶¨Ò壺char* result£»
     2. ×Ö·û´®µÄ×îºóÒ»¸ö×Ö·ûÊÇnull×Ö·û£¨'\0'£©£¬¿ÉÒÔͨ¹ýÕâ¸ö×Ö·ûÈ·¶¨×Ö·û´®µÄ½áβ¡£
     3. strlen()·µ»ØµÄÊÇ×Ö·û´®µÄ´óС£»Òò´Ë£¬ ......

ÔÚLinux C±à³ÌÖÐʹÓÃUnicodeºÍUTF 8

Ŀǰ¸÷ÖÖLinux·¢Ðа涼֧³ÖUTF-8±àÂ룬µ±Ç°ÏµÍ³µÄÓïÑÔºÍ×Ö·û±àÂëÉèÖñ£´æÔÚһЩ»·¾³±äÁ¿ÖУ¬¿ÉÒÔͨ¹ýlocaleÃüÁî²é¿´£º
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPE ......

c/c++±ÊÊÔ


1£®½ø³ÌºÍÏ̵߳IJî±ð¡£
Ïß³ÌÊÇÖ¸½ø³ÌÄÚµÄÒ»¸öÖ´Ðе¥Ôª,Ò²Êǽø³ÌÄڵĿɵ÷¶ÈʵÌå.
Óë½ø³ÌµÄÇø±ð:
(1)µ÷¶È£ºÏß³Ì×÷Ϊµ÷¶ÈºÍ·ÖÅäµÄ»ù±¾µ¥Î»£¬½ø³Ì×÷ΪӵÓÐ×ÊÔ´µÄ»ù±¾µ¥Î»
(2)²¢·¢ÐÔ£º²»½ö½ø³ÌÖ®¼ä¿ÉÒÔ²¢·¢Ö´ÐУ¬Í¬Ò»¸ö½ø³ÌµÄ¶à¸öÏß³ÌÖ®¼äÒ²¿É²¢·¢Ö´ÐÐ
(3)ÓµÓÐ×ÊÔ´£º½ø³ÌÊÇÓµÓÐ×ÊÔ´µÄ¶ÀÁ¢µ¥Î»£¬Ï̲߳»ÓµÓÐϵͳ×ÊÔ´£¬µ«¿ÉÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ