aptitude 命令_C-命令行参数Aptitude问题与解答
aptitude 命令
C programming Command Line Arguments Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on Command Line Arguments – Passing values with running programs, separate argument values, number of arguments etc.
C編程命令行參數(shù)能力問題和解答:在本節(jié)中,您將找到命令行參數(shù)的C能力問題和解答-通過運(yùn)行程序傳遞值,單獨(dú)的參數(shù)值,參數(shù)數(shù)目等。
1) What will be the output of this program (prg_1.c)? If input command isC:\TC\BIN>prg_1 includehelp.com C C++ Java #include <stdio.h> int main(int argc,char* argv[]) {printf("%d",argc);return 0; }
4
5
6
3
5
The first argument of main argc contains the total number of arguments given by command prompt including command name, in this command total arguments are 5. 1)該程序(prg_1.c)的輸出是什么? 如果輸入命令是
C:\ TC \ BIN> prg_1 includehelp.com C C ++ Java
4
5
6
3
5
main argc的第一個(gè)參數(shù)包含命令提示符給出的參數(shù)總數(shù),包括命令名稱,在此命令中,參數(shù)總數(shù)為5。 2) What will be the output of this program (prg_2.c)? If input command is
C:\TC\BIN>prg_2 1,2 "Ok" "Hii" Hello , AAA #include <stdio.h> int main(int counter,char** arg) {unsigned char tally;for(tally=0;tally< counter; tally+=1)printf("%s|",arg[tally]);return 0; }
C:\TC\BIN\PRG_2.EXE|1,2|Ok|Hii|Hello|,|AAA|
ERROR: Invalid argument list.
C:\TC\BIN\PRG_2.EXE|1|,|2|Ok|Hii|Hello|,|AAA|
1,2|Ok|Hii|Hello|,|AAA|
C:\TC\BIN\PRG_2.EXE|1,2|Ok|Hii|Hello|,|AAA|
2)該程序(prg_2.c)的輸出是什么? 如果輸入命令是
C:\ TC \ BIN> prg_2 1,2“確定”“ Hii”您好,AAA
C:\ TC \ BIN \ PRG_2.EXE | 1,2 |確定| Hii |你好|,| AAA |
錯(cuò)誤:無效的參數(shù)列表。
C:\ TC \ BIN \ PRG_2.EXE | 1 |,| 2 | OK | Hii | Hello |,| AAA |
1,2 |確定| Hii |你好|,| AAA |
C:\ TC \ BIN \ PRG_2.EXE | 1,2 |確定| Hii |你好|,| AAA |
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} 3) Which is the correct form to declare main with command line arguments ?
You can choose more than answers.
int main(int argc, char argv[]){ }
int main(int argc, char* argv[]){ }
int main(int argc, char** argv){ }
int main(int* argc, char* argv[]){ }
int main(int argc, char* argv[]){ } and int main(int argc, char** argv){ }
3)用命令行參數(shù)聲明main的正確格式是什么?
您可以選擇多個(gè)答案。
int main(int argc,char argv []){}
int main(int argc,char * argv []){}
int main(int argc,char ** argv){}
int main(int * argc,char * argv []){}
int main(int argc,char * argv []){}和int main(int argc,char ** argv){}
4) What will be the output of this program (prg_2.c)? If input command is
C:\TC\BIN>prg_2 Include Help .Com #include <stdio.h> int main(int argc,char** arg) {printf("%s",arg[argc]);return 0; }
(null)
.Com
Help
C:\TC\BIN>prg_2.exe
(null)
argc contains the total number of arguments passed through command prompt, in this program value of argc will be 3, and the given arguments will store into arg[] from 0 to 2 index.
So arg[argc] => arg[3] will return null. 4)該程序(prg_2.c)的輸出是什么? 如果輸入命令是
C:\ TC \ BIN> prg_2包括幫助.Com
(空值)
.Com
救命
C:\ TC \ BIN> prg_2.exe
(空值)
argc包含通過命令提示符傳遞的參數(shù)總數(shù),在此程序中argc的值為3,并且給定參數(shù)將從0到2索引存儲到arg []中 。
因此arg [argc] => arg [3]將返回null。 .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} 5) What will be the output of this program (prg_2.c)? If input command is
C:\TC\BIN>prg_3 10 20 30 #include <stdio.h> #include <stdlib.h> int main(int argc,char* argv[]) {int answer;answer=atoi(argv[1])+atoi(argv[2]);printf("%d",answer);return 0; }
50
60
0
30
30
1st, 2nd argument of argv are 10 and 20. 5)該程序(prg_2.c)的輸出是什么? 如果輸入命令是
C:\ TC \ BIN> prg_3 10 20 30
50
60
0
30
30
argv的1st , 2nd參數(shù)是10和20。
翻譯自: https://www.includehelp.com/c-programs/c-command-line-argument-aptitude-questions-and-answers.aspx
aptitude 命令
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的aptitude 命令_C-命令行参数Aptitude问题与解答的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: Java RandomAccessFil
- 下一篇: php date( w ),PHP Da
