ÔÚC³ÌÐòÀïºÍshellͨÐÅ
Ò»°ãÎÒÃǵ÷ÓÃshell½Å±¾¶¼ÓÃsystem()À´ÊµÏÖ£¬È»ºó·¢ÏÖsytem·µ»ØÖµ²»ºÃ¿ØÖƶøÇÒת»»Âé·³(»¹ÒªÓÒÒÆ4λ¼´/256)£¬ÓÚÊÇÎÒÓÃpopenÀ´»ñÈ¡shellµÄ·µ»ØÖµ¡£¹ûÈ»ÔÚUnixÊÀ½çÀïÃæ£¬Í¨µÀ¾ÍÊÇÁ¬½á¸÷¸ö·½ÃæµÄÇÅÁº°¡£¡
´úÂëÀý×ÓÈçÏ£º
#include<stdio.h>
#include<stdlib.h>
#include<sys/wait.h>
int main (int argc, char *argv[])
{
char szline[256];
FILE *fp;
if (argc != 2)
{
printf ("usage: %s command\n", argv[0]);
return 0;
}
if ((fp = popen (argv[1], "r")) == NULL)
{
printf ("the command %s not exist\n", argv[1]);
return 0;
}
while (fgets (szline, sizeof (szline) - 1, fp) != NULL)
{
printf ("frome command:%s", szline);
}
pclose (fp);
return 0;
}
PS£ºÆæ¹ÖµÄÊÇÎÒÓÃÈçϺ¯Êý£º
char* get_cmd_result(char* cmd)
{
FILE *fp;
char result[256];
memset (result, 0,sizeof(result));
if((fp=popen(cmd,"r"))==NULL)
{
printf("the command %s not exist\n",cmd);
pclose(fp);
return 0;
}
while(fgets(result,sizeof(result)-1,fp)!=NULL)
{
#ifdef __DEBUG__
g_print("get result is %s\n", result);
#endif
}
pclose(fp);
return result;
}
ÔÚdebian sidϾÍûÎÊÌ⣬ÔÚUbuntu10.04Éϵ÷Óøú¯Êý¾Íû·¨·µ»ØµÄÕýÈ·Öµ£¬µ«ÔÚg¸Ãº¯ÊýÀïresultÊÇÕýÈ·µÄ£¬Õâ¸ö¾Í²»ÊǸÃÎÄÌÖÂÛµÄÎÊÌâÁË¡£
Ïà¹ØÎĵµ£º
[root@ocsser file]# cat array-05.c
//this is a program for two juzheng xiangcheng.
#include <stdio.h>
int main(){
int i,j,m,n;
int g,k,f;
int c[5][6];
& ......
½ñÌì·¢ÏÖµçÄÔ³öÏÖĪÃûÆæÃîµÄÎÊÌ⣬ÈÎÎñÀ¸µÄͼ±ê¶¼ÎÞ·¨Ê¹ÓÃÁË¡£¶øÇÒ×¢²á±íÒ²ÎÞ·¨Ê¹Óá£
´¦Àí·½·¨£º
Ò»¡¢ÏȽâËø×¢²á±í¡£´Ë²½Öèºó¿ÉÒÔÕý³£·ÃÎÊÐÞ¸Ä×¢²á±í¡£
http://zhidao.baidu.com/question/8109053.html?fr=ala0
×¢²á±í±»¹ÜÀíԱͣÓã¬
1¡¢Ð½¨Ò»¸öÎı¾Îļþ£¬ÔÚÆäÖÐÊäÈëÒÔÏÂÄÚÈÝ¡£
[HKEY_CURRENT_USER/Software/Micro ......
µ¥Ïß³Ì
Single-Threaded(static) libc.lib
Debug Single-Threaded(static) & ......
1.ʱ¼ä±íʾ
ÔÚ³ÌÐòµ±ÖÐ,ÎÒÃǾ³£ÒªÊä³öϵͳµ±Ç°µÄʱ¼ä,±ÈÈçÎÒÃÇʹÓÃdateÃüÁîµÄÊä³ö½á¹û.Õâ¸öʱºòÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæÁ½¸öº¯Êý:
#include <sys/time.h>
time_t time(time_t *tloc);
char *ctime(const time_t *clock);
timeº¯Êý·µ»Ø´Ó1970Äê1ÔÂ1ÈÕ0 ......
Ò»Ö±¾õµÃCÓïÑÔµÄÔ¤´¦Àí
Æ÷ÊǸöÃÀÃî¶øÉñÆæµÄ¹¤¾ß£¬ÒÔºó»áÂ½Ðø°Ñ×Ô¼ºÑ§µ½µÄ¹ØÓÚËüµÄÐÂ֪ʶ×ܽá³öÀ´¡£To be continued aways...
Ò»¡¢ #defineÌæ»»
£¨Pointer ON C
, Ch14.2.2£©
³ÌÐòÖÐÀ©Õ¹#define¶¨Òå·ûºÅºÍºêʱ£¬Éæ¼°Èçϼ¸¸ö²½Ö裺
(1) ÔÚµ÷Óúêʱ£¬Ê×ÏȶԲÎÊý½øÐмì²é£¬¿´¿´ÊÇ·ñ°üº¬ÁËÈκÎÓÉ#define ¶¨ÒåµÄ·ûºÅ£¬Èç¹ ......