File tree Expand file tree Collapse file tree 5 files changed +77
-0
lines changed Expand file tree Collapse file tree 5 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Command line application template for C
2
+
3
+ Implement CLI application by editing [ main.c] ( src/main.c ) .
4
+ You may add new files to keep your code clean, if it is allowed in your challenge.
5
+
6
+ ## How to get input parameters
7
+ You can get arguments with ordinary C way, using ` int argc ` and ` char * argv[] ` .
8
+
9
+ ``` c
10
+ int main (int argc, char * argv[ ] )
11
+ {
12
+ // code to run
13
+ return 0;
14
+ }
15
+ ```
16
+
17
+ ## How to output result
18
+ You can use `printf`.
19
+
20
+ ``` c
21
+ printf ("argv[%i]: %s\n", i, argv[i]);
22
+ ```
23
+
24
+ ## How to compile
25
+ To compile, we are using [ clang] ( http://clang.llvm.org/ ) gcc command.
26
+
27
+ If you want to change compile option or etc, please edit [ makefile] ( makefile ) .
Original file line number Diff line number Diff line change
1
+ # コマンドラインアプリケーション(CLI アプリ)作成用テンプレート(C)
2
+
3
+ [ main.c] ( src/main.c ) を編集して、CLIアプリを実装してください。
4
+ チャレンジ内でファイルの作成が許可されていれば、可読性等のためにファイルを分割する事も可能です。
5
+
6
+ ## コマンドライン引数の取得方法
7
+ 通常のC++アプリケーションと同じように、` int argc ` と ` char * argv[] ` を使用してください。
8
+
9
+ ``` c
10
+ int main (int argc, char * argv[ ] )
11
+ {
12
+ // code to run
13
+ return 0;
14
+ }
15
+ ```
16
+
17
+ ## コマンド実行結果の標準出力への出力
18
+ printf等標準出力に出力する任意のメソッドが使用可能です。
19
+
20
+ ``` c
21
+ printf ("argv[%i]: %s\n", i, argv[i]);
22
+ ```
23
+
24
+ ## コンパイルについて
25
+ コンパイルには[ clang] ( http://clang.llvm.org/ ) のgccコマンドを使用しています。
26
+
27
+ コンパイルオプション等を変更する場合は[ makefile] ( makefile ) を変更してください。
Original file line number Diff line number Diff line change
1
+ build :
2
+ - make
3
+ files :
4
+ - makefile
5
+ - src/main.c
6
+ main : src/main.c
7
+ command : ./main
8
+ envConf :
9
+ imageName : " givery/track-base2"
Original file line number Diff line number Diff line change
1
+ main : src/* .c
2
+ gcc -o main src/* .c
3
+ clean :
4
+ rm main
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+
3
+ int main (int argc , char * argv [])
4
+ {
5
+ // start from 1 to ignore script name; argv[0] will be a name of processing file.
6
+ for (int i = 1 ; i < argc ; i ++ ) {
7
+ printf ("argv[%i]: %s\n" , i , argv [i ]);
8
+ }
9
+ return 0 ;
10
+ }
You can’t perform that action at this time.
0 commit comments