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

C C++ Êä³öÖÐÎÄ¡¾×ª¡¿


1. wprintf
Q : sizeof(wchar_t) = ?
A : Ëæ±àÒëÆ÷²»Í¬¡£(ËùÒÔ:ÔÚÐèÒª¿çƽ̨µÄʱºò¾¡Á¿²»ÓÃwchar_t) vc : sizeof(wchar_t) = 2;
Q: ÔÚvcÖУ¬ÎªÊ²Ã´Ö±½ÓʹÓÃwprintf(L"²âÊÔ1234")»áûÓнá¹û
A: ûÓÐÉèÖúÃlocale,ÕâÑù×ö
setlocale(LC_ALL ,
"
chs
"
);
wprintf(L
"
%s
"
,L
"
²âÊÔ1234
"
);
»òÕß(¼ÙÉ赱ǰ»î¶¯codepageΪchs)
char
scp[
16
];
int
cp
=
GetACP();
sprintf(scp,
"
.%d
"
,cp);
setlocale( LC_ALL, scp );
wprintf(L
"
²âÊÔ1234
"
);
2. wcout
Ò»Ñù£¬²»¹ýÉ趨locale,ÇëÓÃstd::locale
     locale loc(
"
chs
"
);
     wcout.imbue(loc);
     wcout
<<
L
"
²âÊÔ1234
"

<<
endl;
ÕâƪÎÄÕÂÓ¦¸ÃÊÇ[netsin
]µÄ³É¹û£¬ÎÒÇڿ죬¼ÇÏÂÀ´¡£
×¢£ºwprintfÊÇCµÄ±ê×¼¿âº¯Êý£¬µ«wcout²»ÊÇC++µÄ±ê×¼³ÉÔ±£¬C++ÖÐµÄ L"……" ÊÇ¿í×Ö·û£¬È´Î´±ØÊÇunicode×Ö·û£¬ÕâÓë±àÒëÆ÷ʵÏÖÏà¹Ø¡£
[ǬÀ¤Ò»Ð¦
]
˵£ºÎªÊ²Ã´ C/C++ ÓïÑÔ°Ñ L"xx" ¶¨ÒåΪÓÉʵÏÖ¾ö¶¨µÄÄØ£¿ÕâÏÔÈ»ÊÇΪÁË C/C++ µÄÆÕÊÊÐÔ¡¢¿ÉÒÆÖ²ÐÔ¡£Bjarne
µÄ¹ÛµãÈÏΪ£¬C++ µÄ·½Ê½ÊÇÔÊÐí³ÌÐòԱʹÓÃÈκÎ×Ö·û¼¯×÷Ϊ´®µÄ×Ö·ûÀàÐÍ¡£ÁíÍ⣬unicode
±àÂëÒѾ­·¢Õ¹ÁËÈô¸É°æ±¾ÁË£¬ÊÇ·ñÄÜÓÀ¾ÃÊʺÏÏÂÈ¥Ò²²»µÃ¶øÖª¡£ÓÐ¹Ø unicode µÄÏêϸÂÛÊöÒÔ¼°ºÍÆäËü×Ö·û¼¯µÄ±È½Ï£¬ÎÒÍƼöÄã¿´¡¶ÎÞ·Ï»°xml¡·¡£
ÒÔÏÂÁ½¶Î´úÂëµÄÖ´Ðл·¾³ÊÇ windows xp professional Ó¢Îİ棬±àÒëÆ÷ÊÇ VS2005RTM¡£
// C
#include <stdio.h>
#include <locale.h>
int main( void )
{
    setlocale( LC_ALL, "chs" );
    //setlocale( LC_ALL, "Chinese-simplified" );
    //setlocale( LC_ALL, "ZHI" );
    //setlocale( LC_ALL, ".936" );
    wprintf( L"Öйú" );
    return 0;
}
// C++
#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
    locale loc( "chs" );
    //locale loc( "Chinese-simpl


Ïà¹ØÎĵµ£º

extern "C" µÄÓÃÒâ

ǰЩÌ죬±à³ÌÐòÊÇÓõ½Á˺ܾÃÒÔǰдµÄC³ÌÐò£¬Ïë°ÑÀïÃæµÄº¯ÊýÀûÓÃÆðÀ´£¬Á¬½Ó·¢ÏÖ³öÏÖÁËÕÒ²»µ½¾ßÌ庯ÊýµÄ´íÎó£º
ÒÔÏÂÊǼÙÉè¾ÉµÄC³ÌÐò¿â
CµÄÍ·Îļþ
/*-----------c.h--------------*/
#ifndef _C_H_
#define _C_H_
extern int add(int x, int y);
#endifCµÄÔ´Îļþ
/*-----------c.c--------------*/
int add(int x, in ......

C/C++ÖеĽṹÌå¶ÔÆëÎÊÌâ(ÄÚ´æ¶ÔÆë)

ÓÉÓÚ³ÌÐòÔËÐÐʱռÓõÄÄÚ´æ¹ý´ó£¬ËùÒÔÏë°ì·¨¸ø³ÌÐòÊÝÉí¡£
ÔÚµ÷ÊÔÖз¢ÏֽṹÌåÕ¼ÓõÄsize¾¹È»ºÍÔ¤ÏëµÄ²»Ò»Ñù£¬Ô­À´……
¿´¿´ÏÂÃæ½²µÄ°É£¬¿Ï¶¨»á²»Í÷´Ë¿´Å¶£¡
1,±ÈÈç:
struct{
    short a1;
    short a2;
    short a3;
}A;
struct{
    ......

C±ê×¼¿â

// Õª×Ô£ºWikipedia.org
CÓïÑԵıê×¼ÎÄÎļþÒªÇóÁËÒ»¸öƽ̨ÒÆÖ²CÓïÑÔµÄʱºòÖÁÉÙҪʵÏÖµÄһЩ¹¦Äܺͷâ×°µÄ¼¯ºÏ£¬³ÆΪ“±ê×¼¿â”£¬±ê×¼¿âµÄÉùÃ÷Í·²¿Í¨¹ýÔ¤´¦ÀíÆ÷ÃüÁî#include½øÐÐÒýÓá£
ÔÚC89±ê×¼ÖУº
     01. <assert.h>
     02. <ctype.h>
&nbs ......

Linux ÏÂc/c++ ±àÒëÆ÷

Gcc¼ò½é
LinuxϵͳϵÄgcc£¨GNU C Compiler£©ÊÇGNUÍƳöµÄ¹¦ÄÜÇ¿´ó¡¢ÐÔÄÜÓÅÔ½µÄ¶àƽ̨±àÒëÆ÷£¬ÊÇGNUµÄ´ú±í×÷Æ·Ö®Ò»¡£gccÊÇ¿ÉÒÔÔÚ¶àÖÖÓ²Ìåƽ̨ÉϱàÒë³ö¿ÉÖ´ÐгÌÐòµÄ³¬¼¶±àÒëÆ÷£¬ÆäÖ´ÐÐЧÂÊÓëÒ»°ãµÄ±àÒëÆ÷Ïà±Èƽ¾ùЧÂÊÒª¸ß20%~30%¡£
gcc ±àÒëÆ÷Äܽ«C¡¢C++ÓïÑÔÔ´³ÌÐò¡¢»ã³Ìʽ»¯ÐòºÍÄ¿±ê³ÌÐò±àÒë¡¢Á¬½Ó³É¿ÉÖ´ÐÐÎļþ£¬Èç¹ûûÓи ......

C51±Ê¼Ç(2) Keil C ³ÌÐòÓÅ»¯

1.         ²ÉÓö̱äÁ¿¡£ÈçbData£¬unsigned char¡£
2.         ÎÞ·ûºÅ±äÁ¿¡£51²»Ö§³Ö·ûºÅÔËËã¡£
3.         ±ÜÃâʹÓø¡µãÖ¸Õë¡£¸¡µãÔËËãʱҪ½ûÖ¹Öжϡ£
4.     &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ