Skip to content

Tag: c++

Output system() in C on one line

I have been trying for hours to create a program that outputs something like command[/home/nerdofcode/]: by running something like: printf(“Command[“, system(“pwd”),”]: “);… But the problem I am receiving is that when I go to type input, it starts typing at command[&#…

Compilation with glibc 2.7 include path fails

I have compiled on my SLES 12.3 g++ 7.3 into the /FaF directory and glibc 2.27 is installed into the /FaF/glibc directory. Compiling this very simple program with g++ -c testAbs.cpp -I /FaF/glibc/include fails horribly: See the long error list. Below I inserted the first 15 lines – in total there are mo…

dup2 paramater order confusion

I have written this simple program: What i want is, redirect the output of ls – l to a file called “theFile.txt”. The code works as i expect. What confuses me here is the order of dup2 parameters. I believe that correct order should be dup2(1, fd) – considering fd as the newFD and 1 as…

Intermittent segmentation faults in main after fork

I’m taking a class on how to learn programming multi process programs on linux on university. I’m still very green and trying my best to learn, so any thing you might see that is wrong would be welcome. I have a problem that asks me to iterate an array, one half on main process, the other half on …

Pass values from C program to Assembly language

I would like to pass values from C program to Assembly using the linked assembly method instead of inline assembly method in C. Below is the Assembly program(GCD) which is am working on. And this is the C program from with I am trying to pass the values to assembly program When I compile using the below metho…