top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What happen in linux system ?

0 votes

There are two files.

    #include <stdio.h>
    void fun1(int i)
            int a;
            printf("Enter the number\n");

    int main()

/* INPUT  */    

What will be in file in OUTPUT file both cases.

./a.out < INPUT  > OUTPUT 

Case-2: Entered value is "18" from key board.

./a.out > output
posted Mar 25, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In both the cases you will get the same answer, I tested on fedora 6.x 64 bit machine and in both the cases the output file contains

Enter the number
answer Mar 26, 2014 by Salil Agrawal
Similar Questions
+4 votes

Lets assume I have a system with RAM of 1GB. and virtual memory is 500MB. That brings to 1.5GB i.e. 1500 MBytes.

I have read somewhere that when I process is created stack of 8MB is associated to that process. So, assuming that any of the process is not allocating any dynamic memory or anything, then does it mean that, Maximum number of process that i can create is 1500/8 and i.e. 187 Process.

Please clarify my understanding,

+3 votes

Please understand the scenario :

I have an embedded system, on which i do telnet and then i starts i run an application using ./binary_name &.
Now if i close the terminal, and if i do telnet from new terminal then i can see above process is still running.

Now, To check this, i have written a sample program,


I just compiled it and i ran it on my linux PC using ./a.out &.
Then i just closed the terminal and from new terminal i checked using ps -elf command this process was killed.

My question is why different behavior for both process. i started both the process in background. Then why?

Any suggestion?

Thanks in advance

+2 votes

If I correct , by default main () function has integer return type.
I want to know what happens in the system internally when its return type gets changed from integer to void ?

+2 votes

Please share a sample program with detail code.

+1 vote

I can write a C program with strings and to pass it to the system to avoid the ugly bash syntax?
My Program

#include <stdlib.h>
#include <stdio.h>

static char command_name[2040] = {0};
int main(int argc, char** argv) {

    if ( argc != 2 ) {
        fprintf(stderr, "Provide command line argument for virtual image \n");
    } else {
            sprintf(command_name, "qemu-kvm -m 1024 %s -netdev user,id=user.0 -device rtl8139,netdev=user.0",


    return system(command_name);

Any suggestions are welcome?