How could you input sound from the microphone on windows in real time?

Something that would let you do something like this:

int main()
    sound sample;
    while (1)
            cout<<"Pitch: "<<sample.getpitch()<<" Volume: "<<sample.getvolume()<<"\n";

Would it be as simple as that, or am I going to have to learn about how to communicate with drivers and stuff?

Something like this for c++ would be nice.

Would it be easier to learn how to do it in python, and then learn how to output data from the python program to a c++ one?

Currently I know nothing about python.

You could get your C++ program to run a Python script which gets the required data and then it puts it in a file, or returns it to you(I'm not sure how) and then do stuff with that data.