How can I make a raspberry pi send info about a button to a c++ program?

I’m trying to connect my rasberry pi 3 b+ send if a button is pressed or not and make the program perform an action depending on the button state. Can you tell me how can i do it? Thanks in advance.