tags:

views:

63

answers:

1

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

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream>

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

Now, when I run that, it comes up, with me needing to press Y, then Enter. How can I simulate that?

+1  A: 

As Tyler said in a comment, a batch file would be much easier, but this might work:

system( "echo y | format f:" )
Graeme Perrow