Tag: ubuntu 10.04

C编程 – Scanf无法在ubuntu中运行

我正在Ubuntu 10中编写一个C程序来创建进程,显示进程ID并终止进程。 我正在使用kill()命令来终止用户通过scanf输入的进程ID。 但是,scanf根本不起作用。 我尝试在%d之前添加“空格”但没有发生任何事情。 感谢是否有人可以提供帮助! 以下是我的代码: include include include include include main () { int x; int pid[10]; // to store fork return value int p[10]; // to store process ID // Create 5 new processes and store its process ID for (x=1;x<=5;x++) { if ((pid[x]=fork())==0) { p[x]=getpid(); printf("\n I am process: %d, my […]

MPI意外输出

我正在阅读和练习教程中的MPI程序。 在那里,我看到了一个寻找流程等级的例子。 但同样的例子是在我的机器上给出不同的输出(Ubuntu 10.04)..这是程序 #include #include main(int argc, char **argv) { int ierr, num_procs, my_id; ierr = MPI_Init(&argc, &argv); /* find out MY process ID, and how many processes were started. */ ierr = MPI_Comm_rank(MPI_COMM_WORLD, &my_id); ierr = MPI_Comm_size(MPI_COMM_WORLD, &num_procs); printf(“Hello world! I’m process %i out of %i processes\n”, my_id, num_procs); ierr = MPI_Finalize(); } […]

在Ubuntu 10.04上编译时未声明PATH_MAX

我正在尝试在8.04版本的Ubuntu 10.04中编译一个C程序。 它失败了,因为我们使用了PATH_MAX和其他应该在limits.h定义的常量。 根据各种资源,它应该是POSIX兼容的C库的一部分。 这是Ubuntu 10.04中的错误还是有正确的解决方法?

Linux / bash中程序返回值的有效范围是多少?

我有一个C程序,它返回一个整数值。 我很惊讶地发现,当从shell提示符检查返回值时,我得到的值为模数256。 /* prog.c */ int main(…) { return 257; } – > ./prog.e > echo $? 1 为什么我看不到整数? 这种行为记录在哪里? 如何将整个32位值获取到shell?