Here is a very basic example on how to limit and printing the FPS when you are using GLUT. Although GLUT is very outdated (FreeGLUT might still be a viable option though), this will point you in the right way when you are trying to achieve this.
The timer function
The timer function is what selects when to update the frame. It measures the time taken to draw the frame and allows the program to sleep when not drawing. Notice that the int flag variable is unused.
The display function
Here, we are using a very simple display function, the functions called are simple drawing the frame and GUI, while we are sending the processor clock value to the fpsTimer class for processing.
The fpsTimer class
This class handles the measuring of FPS over an average number of frames and updates the text after that number of frames have passed, to reduce the flicker of the text. What these functions basically do, are to calculate the time since the last frame, average it and return the text string.
Printing the FPS on screen
The final step is to print the fps on screen using the following call and function: