improve for snippet for c/c++