C/C++³ÌÐòÄÚ´æ·ÖÅäÏê½â
·ÇʱÉСñ2010ÐÂ¿î ¹¬Í¢¸´¹ÅÂÞÂíЬÕæƤÁ¹Ð¬ÊæÊÊƽµ×ЬŮЬ
189.0Ôª
Ò»¸öÓÉC/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ³ÌÐòÔËÐÐʱÓɱàÒëÆ÷×Ô¶¯·ÖÅ䣬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£³ÌÐò½áÊøʱÓɱàÒëÆ÷×Ô¶¯ÊÍ·Å¡£
2¡¢¶ÑÇø£¨heap£© — ÔÚÄڴ濪±ÙÁíÒ»¿é´æ´¢ÇøÓò¡£Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅ䷽ʽµ¹ÊÇÀàËÆÓÚÁ´±í£¬ºÇºÇ¡£
3¡¢È«¾ÖÇø£¨¾²Ì¬Çø£©£¨static£©—±àÒëÆ÷±àÒëʱ¼´·ÖÅäÄڴ档ȫ¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿µÄ´æ´¢ÊÇ·ÅÔÚÒ»¿éµÄ£¬³õʼ»¯µÄ È«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿ÔÚÒ»¿éÇøÓò£¬ δ³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍδ³õʼ»¯µÄ¾²Ì¬±äÁ¿ÔÚÏàÁÚµÄÁíÒ»¿éÇøÓò¡£ - ³ÌÐò½áÊøºóÓÉϵͳÊÍ·Å
4¡¢ÎÄ×Ö³£Á¿Çø —³£Á¿×Ö·û´®¾ÍÊÇ·ÅÔÚÕâÀïµÄ¡£ ³ÌÐò½áÊøºóÓÉϵͳÊÍ·Å
5¡¢³ÌÐò´úÂëÇø—´æ·Åº¯ÊýÌåµÄ¶þ½øÖÆ´úÂë¡£
Àý×Ó³ÌÐò
ÕâÊÇÒ»¸öÇ°±²Ð´µÄ£¬·Ç³£Ïêϸ
//main.cpp
int a = 0; È«¾Ö³õʼ»¯Çø
char *p1; È«¾Öδ³õʼ»¯Çø
main()
{
int b;// Õ»
char s[] = "abc"; //Õ»
char *p2; //Õ»
char *p3 = "123456"; //"123456\0"ÔÚ³£Á¿Çø£¬p3ÔÚÕ»ÉÏ¡£
static int c =0£» //È«¾Ö£¨¾²Ì¬£©³õʼ»¯Çø
p1 = (char *)malloc(10);
p2 = (char *)malloc(20);
//·ÖÅäµÃÀ´µÃ10ºÍ20×Ö½ÚµÄÇøÓò¾ÍÔÚ¶ÑÇø¡£
strcpy(p1, "123456"); //123456\0·ÅÔÚ³£Á¿Çø£¬±àÒëÆ÷¿ÉÄܻὫËüÓëp3ËùÖ¸ÏòµÄ"123456"ÓÅ»¯³ÉÒ»¸öµØ·½¡£
}
===============
CÓïÑÔ³ÌÐòµÄÄÚ´æ·ÖÅ䷽ʽ
1.ÄÚ´æ·ÖÅ䷽ʽ
ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
[1]´Ó¾²Ì¬´æ ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄÕû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static±äÁ¿¡£
[2]ÔÚÕ»ÉÏ´´½¨¡£ ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ´¦ÀíÆ÷µÄÖ¸ÁÖУ¬Ð§Âʺܸߣ¬µ« ÊÇ·ÖÅäµÄÄÚ´æÈÝÁ¿ÓÐÏÞ¡£
[3]´Ó¶ÑÉÏ·ÖÅ䣬Òà³Æ¶¯Ì¬ÄÚ´æ·ÖÅä¡£³ÌÐòÔÚÔËÐеÄʱºòÓÃmalloc»ònewÉêÇëÈÎÒâ¶àÉÙµÄÄڴ棬³ÌÐòÔ±×Ô¼º¸ºÔðÔÚºÎʱÓÃfree»òdeleteÊÍ·ÅÄÚ´æ¡£¶¯Ì¬ÄÚ´æµÄÉú´æÆÚÓɳÌÐòÔ±¾ö¶¨£¬Ê¹Ó÷dz£Áé»î£¬µ«Èç¹ûÔÚ¶ÑÉÏ·ÖÅäÁ˿ռ䣬¾ÍÓÐÔðÈλØÊÕËü£¬·ñÔòÔËÐеijÌÐò»á³öÏÖÄÚ´æй©£¬Æµ·±µØ·ÖÅäºÍÊͷŲ»Í¬´óСµÄ¶Ñ¿Õ¼ä½«»á²úÉú¶ÑÄÚËé¿é¡£
2.³ÌÐòµÄÄÚ´æ¿Õ¼ä
Ò»¸ö³ÌÐò½«²Ù×÷ ϵÍ
Ïà¹ØÎĵµ£º
int svd(int m,int n,int withu,int withv,double eps,double tol,
double *a, double *q, double *u, double *v, double *vt)
{
int i,j,k,l,l1,iter,retval;
double c,f,g,h,s,x,y,z;
double *e;
e = (double *)calloc(n,sizeof(double));
retval = 0;
/* Cop ......
In C++, how do i go about using setenv to set the display? I need to set it like this:
export DISPLAY=0.0
1¡¢setenv("DISPLAY",":0.1",1);
If you're calling the xrandr functions from your C++ program, then I would expect setenv() should work for you. The 3rd argument of 1 tells setenv() to ov ......
CµÄstaticµÄÓ÷¨:
1.¶ÔÓÚº¯ÊýÀïµÄ¾Ö²¿±äÁ¿,¸Ä±äµÄÊÇËüµÄÉú´æÖÜÆÚ,Õâ¸ö±äÁ¿»áÒ»Ö±´æÔÚ,µ½³ÌÐò½áÊø. º¯ÊýÍⲿ·ÃÎʲ»µ½Õâ¸ö±äÁ¿.
2.¶ÔÓÚÈ«¾ÖµÄ±äÁ¿,¸Ä±äµÄÊÇËüµÄ×÷Ó÷¶Î§,Õâ¸ö±äÁ¿Ö»ÔÚ±¾ÎļþÄÚÓÐЧ.ÆäËüµÄ.cÎļþ¿´²»µ½.
µ±È»ËüµÄÉúÃüÖÜÆÚÊǺͳÌÐòÒ»ÑùµÄ ......
×öµ½×¨Òµ£¬Ó¦¸ÃÊÇÿ¸öÖ°Òµ³ÌÐòÔ±Ó¦¸ÃÒªÇó×Ô¼º×öµ½µÄ¡£
ÈÃÎÒÃÇ¿´¿´lua
ÊÇ
ÔõôдͷÎļþµÄ¡£
1.License Agreement
License
Agreement
Ó¦¸Ã¼ÓÔÚÿ¸öÍ·ÎļþµÄ¶¥²¿¡£
Lua Sample:
/*
** $Id: lua.h,v 1.175b 2003/03/18 12:31:39 roberto Exp $
** Lua - An ......