🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.ibm.pc.programmer
1 messages
1 total messages Started by D. Richard Hipp Mon, 30 Jul 1990 13:19
How to format an MS-DOS disk from C?
#1023
Author: D. Richard Hipp
Date: Mon, 30 Jul 1990 13:19
25 lines
1243 bytes
I need to format a floppy disk under program control (Turbo-C 1.5).  Right
now I am using the function listed below.  It works, but relies on the
presence of COMMAND.COM.  It also does some needless disk I/O, and will
not run on a single disk computer.  Does anyone know how to format a
floppy disk directly?  Respond by mail and I will post a summary after
two weeks.  Thanx.

/*
** Format a disk.  "arg" is the argument to the DOS format command.
** Return false if a temporary file can not be opened.
*/
boolean format(char *arg){
  FILE *fp;
  char cmd[200];

  assert( strlen(arg)<160 );
  if( (fp=fopen("temporar.y","w"))==0 ) return false;
  fprintf(fp,"\nn\n");
  fclose(fp);
  sprintf(cmd,"format %s <temporar.y >temporar.y2",arg);
  system(cmd);
  unlink("temporar.y");
  unlink("temporar.y2");
  return true;
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads