In strengthening a result of Andrásfai, Erdős and Sós in 1974, Häggkvist proved that if G is an n-vertex C_{2k+1}-free graph with minimum degree δ(G)>2n/(2k+3) and n>(k+2)(k+1)/2 (2k+3)(3k+2),then G contains no odd cycle of length greater than (k+1)/2.This result has many applications. In this paper, we consider a similar problem by replacing the minimum degree condition with the edge number condition. We prove that for integers n,k,r with k≥2,3≤r≤2k and n≥2(r+2)(r+1)(r+2k), if G is an n-vertex C_{2k+1}-free graph with e(G)≥(n-r+1)^2/4+(r¦2),then G contains no odd cycle of length greater than r. The construction shows that the result is best possible.This extends a result of Brandt [Discrete Applied Mathematics 79 (1997)], and a result of Bollobás and Thomason [Journal of Combinatorial Theory, Series B.77 (1999)], and a result of Caccetta and Jia [Graphs Combin. 18 (2002)] and independently proving by Lin, Ning and Wu [Combin. Probab. Comput. 30 (2021)]. Recently, Ren, Wang, Yang, and the second author [SIAM J. Discrete Math. 38(2024)] show that for 3 ≤ r ≤ 2k and n ≥ 318(r-2)²k, every n-vertex C_{2k+1}-free graph with e(G)≥(n-r+1)^2/4+(r¦2)can be made bipartite by deleting at most r-2vertices or deleting at most (⌈(r+1)/2⌉¦2)+(⌊(r+1)/2⌋¦2) edges. As an application, we derive this result and provide a simple proof.