I have a csr(Certificate Signing Request).
I have to just change the CN from that csr, leaving other fields intact. It is like updating the existing csr.
This should be done automatically. Is there any method to do this in c/c++/openssl?
You cannot change anything in the request file, because it is a digitally signed message. If you change at least one bit there, you invalidate the signature. CA server will reject it.
What you can do: