diff --git a/primary/pr/docs/How-to-submit-a-PR/How-to-submit-a-PR.md b/primary/pr/docs/How-to-submit-a-PR/How-to-submit-a-PR.md index 16aea0712a65c88a33986aa4aed2aba4d7b8b53c..cabc11089cbe03cbe16771facc02ea033c2cf00b 100644 --- a/primary/pr/docs/How-to-submit-a-PR/How-to-submit-a-PR.md +++ b/primary/pr/docs/How-to-submit-a-PR/How-to-submit-a-PR.md @@ -213,15 +213,14 @@ https://gitee.com/openeuler/community/blob/master/en/sig-infrastructure/command. -## V 运行本仓库中的程序 +## V 运行hello程序 -可以运行仓库中的main.c程序以观看提交后的效果。该main程序可以在Linux和类UNIX的macOS上运行。在Windows上,您可以看一下[openEuler开源创新实践课](https://gitee.com/openeuler/lfs-course/tree/master/lfs-7.7-systemd)中是如何创建虚拟机并安装openEuler操作系统以运行程序的。编译和运行该程序的命令如下所示: +可以编译、运行src目录下的hello.c程序以观看提交后的效果,该程序可以在Linux和类UNIX的macOS上运行,下面是一个示例: ```shell -cd primary/pr/src/ -gcc main.c -./a.out +gcc hello.c -o hello +./hello ../../../playground/pr/ ``` 这样,凡是正确提交并被合入PR了的Gitee-ID都可以在电脑屏幕上被打印出来…… :) diff --git a/primary/pr/src/main.c b/primary/pr/src/hello.c similarity index 63% rename from primary/pr/src/main.c rename to primary/pr/src/hello.c index 8869f0dfb5aadff98ae41beceb4b7eec71565d2c..909133efdd4ffe7dd3449fdc1c8cbcd8f84592de 100644 --- a/primary/pr/src/main.c +++ b/primary/pr/src/hello.c @@ -1,11 +1,13 @@ /* - * main.c + * hello.c * * This program runs on Linux and UNIX-like macOS. * * Compile and run the program: - * gcc this-file - * ./a.out + * gcc hello.c -o hello + * ./hello PATH-TO-PR-PLAYGROUND + * 其名称设置成Gitee-ID的文件默认置于playground的pr目录。相对于当前目录,则为: + * ./hello ../../../playground/pr/ */ #include @@ -13,12 +15,16 @@ #include #include -int main() { - // 其名称设置成Gitee-ID的文件将置于本程序的上级目录 - DIR *dir = opendir("../../../playground/pr/"); +int main(int argc, char *argv[]) { + if (argc < 2) { + printf("\nUsage:\n%s PATH-TO-PR-PLAYGROUND\n\n", argv[0]); + return 0; + } + + DIR *dir = opendir(argv[1]); if (dir == NULL) { - perror("Unable to open parent directory"); - return 1; + perror("Unable to open PR playground directory"); + return -1; } struct dirent *entry; @@ -40,3 +46,4 @@ int main() { printf(":)\n"); return 0; } +