This paper proposes a novel real-time formation control and obstacle avoidance algorithm for multiple fixed-wing UAVs. A formation control algorithm is designed by a combination of the virtual structure, leader-follower, and artificial potential fields methods and harnessing the advantages of those approaches. The kinematic and dynamic constraints of fixed-wing UAVs are considered in the path planning. The performance of the proposed algorithm is examined through simulation in Matlab software by applying the translational dynamics of fixed-wing UAVs. Simulations of different complex scenarios demonstrate the effectiveness of the presented formation flight algorithm through generating multiple efficient paths, which are fully consistent with the functional constraints of the UAVs in the presence of obstacles.