I need to write a C program in the LINUX such that
First Condition: from morning 8 am to evening 6 pm and also if the number of packets in the network which is being counted by the Tshark in the terminal window is greater than 500 then Switch will be turned ON and if the packets is less than 500 the HUB should turn ON.
Second condition is from evening 6 pm to morning 7.59 am and if the number of packets is less than 500 in the network then HUB will be turned ON and if it is greater than 500 Switch will be turned ON.

So the help I need is to write a C program that should monitor/count the Tshark packets in the terminal window and also simultaneously the system time, these both are important aspects.

Reading the output of another terminal is a non-trivial task. What level of experience do you have?
Are you able to start the tshark program yourself instead of trying to read another terminal? What is the timeframe for number of packets? 500 per second, per minute, per hour, per 8-6 shift?

I am the beginner, what is required is to monitor the system time continuosly, in order to do that what are the commands do i need to use, please help me..

You might want to start by looking at gettimeofday and placing that in some kind of loop. However, you will also need to manage the other activities within that loop so you may want to look at either threads or child processes for handling each of the tasks.
I might add that C may not be the best choice for such an activity - especially for a beginner. There are other languages with libraries that make doing what you want a bit easier that writing it directly in C - Python comes to mind.

This article has been dead for over six months. Start a new discussion instead.