Auto Format

So, I am trying to create a program that auto formats my f:\ (USB Drive), and I have this code so far:

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream>

int main ()
{
  system ("format c:");
  system("pause");
  return 0;
}


Now, when I run that, it comes up, with me needing to press Y, then enter. I was wondering how I can simulate that. Thanks
well you have C as your drive, so thats a good thing that it prompts or you would of been out of a windows partition.
Haha, yea, I fixed that :)
also system() is evil...try and search the windows API for a function that calls the commands for formating without having to call the program format. You should be able to automate it easier through that.
How is system evil, and also, I searched, I couldnt find a function to replace the console format function.
it introduces a massive security leak into your program. For instance, if some one replaced the pause program with a virus. or in this case, format. It's not safe. thats why most professional programmers avoid it when ever they can.
Topic archived. No new replies allowed.