Insert in a file without overwriting without using a 2nd file using C/C++

The below are the contents in a text file.

name1: 1234
name2: 2000
name3: 3000

This is an existing text file and I want to replace one value(say 1234) with another value (say 12345) in the text file. so I placed the cursor at start of the value (here its the 7th position) . Then i used the following statement:

fprintf(filepointer,"12345\n");

The resultant file is like

name1: 12345
ame2 : 2000
name3 : 3000

Its overwriting the 4 characters("1000") and a newline('\n') and 'n' with 5 characters("12345") and a newline('\n').

The solutions I know are:
1. Overwriting the entire file to add one extra character.
2. Copying each line in a linked list node and change the characters in the memory and write in the same file.
3. Create a temp file and copy the new characters to the desired place in the temp file and change the name of the temp file to source file name and delete the source file.

Windows (COM), Send bytes to serial port

Hello everyone, I'm trying to make a Windows program that sends data to a microcontroller, through serial port (usb emulating com).

Till now, I made it with ASCII, but I have to do a job with a classmate, that said me, that I don't have to do that; That I have to send directly to the serial port, the bytes that He needs to use (He program the microcontroller, I, the Windows interface).

I always used writefile with ASCII, in the form:

WriteFile(handlePort,bufferPort,(strlen(buffer_puerto)),&nBytes,NULL);

I have to send a byte chain, like 10000001 10010001 0000000 10100001 11101101.

The problem is, that when Writefile detects the third byte 00000000, interprets it like a null character '\0' and do not send more bytes.

Please, could anyone help me. Is there any way to send all bytes (after the third 00000000) without lost information?

Is There another function apart writefile that can it make that?
How should I do it?

Thanks in advance.
Greetings
Wait while more posts are being loaded