DICOM dataset can be easily written to a file:
DcmDataset dataset; // ... DcmFile file("dicom.dcm"); file.write(dataset);By default Implicit Little Endian transfer syntax (1.2.840.10008.1.2) is used when writing DICOM files. But any other syntax can be used as well:
DcmDataset dataset; // ... DcmFile file("dicom.dcm"); file.write(dataset, DcmTransferSyntax::ExplicitLittleEndian);Pay attention that TransferSyntaxUID (0002, 0010) tag in a dataset object is modified according to the syntax used when writing a file.