亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1636 | 回復(fù): 3
打印 上一主題 下一主題

請教一下system函數(shù)的用法 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2006-08-18 19:11 |只看該作者 |倒序瀏覽
我想在c語言中調(diào)用mount命令,可不可以采用下面的語句呢。
char *tmp;
sprintf(tmp,"/bin/mount -t vfat %s /mnt/usb",dev);
system(tmp);
其中dev是/dev/sda1。
這樣可以實現(xiàn)嗎?

論壇徽章:
0
2 [報告]
發(fā)表于 2006-08-18 19:40 |只看該作者
應(yīng)該可以的,最好命令行后加"&",讓其后臺執(zhí)行.
char *,應(yīng)改成char str[256];否則存在溢出問題!

[ 本帖最后由 aiwin28 于 2006-8-18 19:41 編輯 ]

論壇徽章:
0
3 [報告]
發(fā)表于 2006-08-18 22:57 |只看該作者
原帖由 liuchang1881 于 2006-8-18 19:11 發(fā)表
我想在c語言中調(diào)用mount命令,可不可以采用下面的語句呢。
char *tmp;
sprintf(tmp,"/bin/mount -t vfat %s /mnt/usb",dev);
system(tmp);
其中dev是/dev/sda1。
這樣可以實現(xiàn)嗎?

>>
>>
>>答案是可以。參考如下:
>>
>>
NAME
       system - execute a shell command

SYNOPSIS
       #include <stdlib.h>

       int system(const char *string);

DESCRIPTION
       system()  executes  a command specified in string by calling /bin/sh -c
       string, and returns after the command has been completed.  During  exe‐
       cution  of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT
       will be ignored.

RETURN VALUE
       The value returned is -1 on error (e.g. fork failed),  and  the  return
       status  of  the command otherwise.  This latter return status is in the
       format specified in wait(2).  Thus, the exit code of the  command  will
       be  WEXITSTATUS(status).   In  case  /bin/sh could not be executed, the
       exit status will be that of a command that does exit(127).

       If the value of string is NULL, system() returns nonzero if  the  shell
       is available, and zero if not.

       system() does not affect the wait status of any other children.

論壇徽章:
0
4 [報告]
發(fā)表于 2006-08-21 09:37 |只看該作者

請教一下exit函數(shù)!

在讀程序的時候,經(jīng)常會看到exit函數(shù),例如exit(0),exit(-1),exit(-2)等,
它們各自代表什么意思呢,之間的區(qū)別是什么?
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP