C/C++º¯Êý²ÎÊý,´«ÖµÓò´«Ö·!!!
/*
* File: main.cpp
* Author: Vicky
*
* Created on 2010Äê5ÔÂ8ÈÕ, ÏÂÎç2:47
*/
#include <iostream>
using namespace std;
void swap(int x, int y) {
cout << "x and y swap before : " << x << "\t" << y << endl;
int i = x;
x = y;
y = i;
cout << "x and y swap after : " << x << "\t" << y << endl;
}
void swap2(int * x, int * y) {
cout << "x and y swap before : " << *x << "\t" << *y << endl;
int * i = x;
x = y;
y = i;
cout << "x and y swap after : " << *x << "\t" << *y << endl;
}
/**
* ×¢Òâ,´Ë´¦·Ç&xÓë&y²¢·ÇµØÖ·,¶øÊǶÔÏóµÄ±ðÃû!!!
*/
void swap3(int &x, int &y) {
cout << "x and y swap before : " << x << "\t" << y << endl;
int i = x;
x = y;
y = i;
cout << "x and y swap after : " << x << "\t" << y << endl;
}
/**
* °´Ö·´«µÝ,´«µÝµÄ²ÎÊýÊǵØÖ·.
*/
void swap4(int * x, int * y) {
cout << "x and y swap before : " << *x << "\t" << *y << endl;
int i = *x;
*x = *y;
*y = i;
cout << "x and y swap after : " << *x << "\t" << *y << endl;
}
int main(int argc, char** argv) {
int x = 1;
int y = 9;
cout << "main function swap before : " << x << "\t" << y << endl;
swap(x, y);
cout << "main function swap after : " << x << "\t" << y << endl;
// ¿É½«,Ö÷º¯ÊýµÄxÓëy²¢Ã»Óн»»»,±íʾswapº¯Êý½»»»µÄ½ö½öÊÇxÓëyµÄ¸±±¾
cout << "---------" << endl;
int * px = new int(1);
int * py = new int(9);
cout << "main function swap before : " << *px << "\t" << *py << endl;
swap2(px, py);
cout << "main function swap after : " << *px << "\t" << *py << en
Ïà¹ØÎĵµ£º
ÔÚ Web Ó¦ÓóÌÐò»·¾³ÖУ¬µü´úÖ÷ÒªÓÃÓڷôæºÍÏÔʾÊý¾Ý¼¯£¬Í¨³£ÊÇÒÔÁбí»ò±íÖеÄһϵÁÐÐеÄÐÎʽÏÔʾ¡£ÊµÏÖµü´úÄÚÈݵÄÖ÷Òª JSTL ²Ù×÷ÊÇ <c:forEach>; ¶¨ÖƱê¼Ç¡£¸Ã±ê¼ÇÖ§³ÖÁ½ÖÖ²»Í¬ÑùʽµÄµü´ú£ºÕûÊý·¶Î§Éϵĵü´ú£¨ÀàËÆ Java ÓïÑ﵀ for Óï¾ä£©ºÍ¼¯ºÏÉϵĵü´ú£¨ÀàËÆ Java ÓïÑ﵀ Iterator ºÍ Enumeration Àࣩ¡£
½øÐÐÕûÊ ......
CºÍC++ÖеÄÖ÷ÒªÊý¾ÝÀàÐͺÍ×Ö½Ú´óС(
C/C++µÄд·¨ÊDz»¿ÆѧºÍ²»ÑϽ÷µÄ¡£ÒòΪCºÍC++ËäÈ»ÓïÒ壬µ«ÊÇÉè¼Æ˼ÏëÊǽṹ»¯ÓëÃæÏò¶ÔÏó. C±ê×¼¹æ·¶ÓëC++µÄ±ê×¼¹æ·¶Ò²ÊÇÁ½¸öÎı¾¡£½üÀ´×ÐϸÑо¿ÁËËüÃǵÄÊý¾ÝÀàÐÍ£¬²ÅÖªµÀÆäÀ´ÁúÈ¥Âö£¬ÕæÕý×öµ½ÆäʵËùÒÔÈ»¡£
1¡¢CÓïÑÔ¶¨ÒåÁË5ÖÖ»ù±¾Êý¾ÝÀàÐÍ
char(×Ö·û), int(Õ ......
ѧ¶«Î÷£¬ÍùÍùʵÀý²ÅÊÇ×îÈÃÈ˸ÐÐËȤµÄ£¬ÀÏÊÇѧ»ù´¡ÀíÂÛ£¬²»¶¯ÊÖ£¬¸Ð¾õûÓгɾ͸У¬ºÇºÇ¡£
ÏÂÃæÏÈÀ´Ò»¸öʵÀý¡£ÎÒÃÇͨ¹ý´´½¨Á½¸öÏß³ÌÀ´ÊµÏÖ¶ÔÒ»¸öÊýµÄµÝ¼Ó¡£
»òÐíÕâ¸öʵÀýûÓÐʵ¼ÊÔËÓõļÛÖµ£¬µ«ÊÇÉÔ΢¸Ä¶¯Ò»Ï£¬ÎÒÃǾͿÉÒÔÓõ½ÆäËûµØ·½È¥À¡£
ÏÂÃæÊÇÎÒÃǵĴúÂ룺
/*thread_example.c : c multiple thread p ......
×î½üÐèҪдһ¶Î³ÌÐò£¬Íê³ÉÒÔÏµĹ¤×÷£¬ÓÃjava½«Êý¾ÝÒÔ¶þ½øÖƵÄÐÎʽдÈëÎļþÖУ¬È»ºóÓÃC¶Á³ö´Ë¶þ½øÖÆÎļþ¡£
¿ªÊ¼µÄʱºòûÓп¼ÂÇ»úÆ÷µÄ×Ö½ÚÐò£¬Ö±½Ó¸ã³ösegment fault.ÏëÁ˺ܾ㬲ÅÃ÷°×ÔÀ´ÊÇjavaºÍCµÄ×Ö½ÚÐòÊDz»Ò»ÑùµÄ¡£
javaÖеÄ×Ö½ÚÐòÊÇbig endianµÄ£¬ËüÊÇÓë»úÆ÷Î޹صġ£¶øcµÄ×Ö»úÐòÊÇ»úÆ÷Ïà¹ØµÄ£¬¶øµ±Ç°ÓõĻúÆ÷ÊÇx84 ......