Q:

Why my scanf catch the order that I give from my Popen

TL;DR: How to make my scanf(must be scanf) reads the input from a python?
So I have this file in python
import subprocess
import sys

process=subprocess.Popen(["canCHandleIt.exe"],stdout=subprocess.PIPE)
res=process.communicate(2)
print res[0]

The point is simple. I want my C to catch the number "2" and print success twice, as my c code suggested.
#include <stdio.h>
int main(){
    int x;int o;
    scanf("%d",&x);
    for (o=0;o<x;o++){
    printf("Sucsess!");
    }
}

But it just stops. Of course if type the number 2, then it will work, but I want my scanf works alone.
Some may suggest that I should just used C equivalent to Python's sys.stdin.readline(), but I really want my scanf works without human interference. (The reason I asked this, is because I often people use scanf in contest and I want to replicate the contest bot,in python obviously.)
You can assume that I have gcced my c file.

A:

Try this:
import subprocess
import sys

process=subprocess.Popen(["canCHandleIt.exe"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
res=process.communicate('2')
print res[0]

...the key differences being stdin=subprocess.PIPE passed to Popen(), and passing "2" as a string, not an int, into communicate().
It is documented for communicate() that :

The optional input argument should be a string to be sent to the child
  process.....

and

Note that if you want to send data to the process’s stdin, you need to
  create the Popen object with stdin=PIPE.

