我试图显示...(三个点),但每个点然后是第二个延迟,然后是第二个点,然后是第二个延迟,然后是第三个点.
我试过这个
for(int i = 0;i < 3;i++)
{
sleep(1);
printf(".");
sleep(1);
}
Run Code Online (Sandbox Code Playgroud)
但这只是等待了6秒然后将三个点打印在一起,但我不想要那样.有没有解决这个问题.我想要
.第二次延迟.第二次延迟.
但它会出现
...
int train [4] [3] = { 0, 0, 0,
0, 1, 0,
1, 0, 0,
1, 1, 1 };
Run Code Online (Sandbox Code Playgroud)
这是C++中2d数组的有效初始化
行将是0,0,0(第1行),(0,1,0)(第2行),(1,0,0)(第3行)和(1,1,1)(第4行)?
它是否相当于
int train [4] [3] = {{0, 0, 0},
{0, 1, 0},
{1, 0, 0},
{1, 1, 1}};
Run Code Online (Sandbox Code Playgroud) 所以我知道exec*
函数之后的所有内容都不会被执行(如果exec*调用当然是成功的话).
我想明白为什么会这样?所以我开发了这个小小的程序
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
printf("A program made to understand execvp\n");
char *cmd[4] = {"ls", "-l","file",NULL};
execvp(cmd[0],cmd);
printf("This will not be printed!!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我所理解的是,bin目录中的可执行命令实际上是可执行程序,因此基本上从我们的程序中调用另一个程序.
而且我确实读到了某个地方
如果成功,exec系统调用不会返回调用程序,因为调用图像丢失.
但这究竟意味着什么,为什么他们不回到调用程序?他们如何回归呢?