title: What is the purpose of including the stdafx.h file in a C++ program using opencv
body: <p>here is a sample code. If I remove the stdafx.h file, the program wont compile.</p>
  
  <p>stdafx.h file</p>
  
  <pre><code>'#pragma once
  
  '#include "targetver.h"
  
  '#include &lt;stdio.h&gt;
  '#include &lt;tchar.h&gt;
  </code></pre>
  
  <p>Capture.ccp</p>
  
  <p>// Capture.cpp : Defines the entry point for the console application.
  //</p>
  
  <pre><code>'#include "stdafx.h"
  '#include "string.h"
  '#include "cv.h"
  '#include "highgui.h"
  
  
  
  
  int _tmain(int argc, char ** argv[])
  {
  CvCapture * pCapture = 0;
  IplImage * pVideoFrame = 0;
  int i;
  char filename[50];
  
  //Initialize vieo capture
  pCapture = cvCaptureFromCAM( CV_CAP_ANY );
  if( !pCapture )
  {
      fprintf(stderr, "failed to initialize video capture\n");
      return -1;
  }
  
  //Capture three video frames and write them as files
  for(i=0;i&lt;20;i++)
  {
      pVideoFrame = cvQueryFrame( pCapture );
      if( !pVideoFrame )
      {
          fprintf(stderr, "failed to get a video frame\n");
      }
  
      //Write the captured video frame as an image file
      sprintf(filename, "VideoFrame%d.jpg", i+1);
      if( !cvSaveImage(filename, pVideoFrame))
      {
          fprintf(stderr, "faile dto write image file %s\n", filename);
      }
  
      //IMPORTANT : Don't release or modify the image returned 
      //from cvQueryFrame() !
  }
  
  //Terminate video capture and free capture resources
  cvReleaseCapture( &amp;pCapture );
  return 0;
  }
  </code></pre>
  
  <hr>
  
  <p>What is the purpose of the stdafx.h file - this file by the way is generated automatically.</p>
  
  <p>Many Thanks</p>