Could you help me with this code ? how to do that you told by code ?
Which part?
Make your array one element larger.
This could hardly be simpler:
char buf[10]; --> char buf[11];
Capture the return value from File::read()
myFile.read(buf,10); --> int charCnt = myFile.read(buf,10);
and use that value as an array index, and store a NULL at that location.
buf[charCnt] = '\0';