Stuck With An Error For My Code

I'm having issues with this code I'm doing and I was wondering how I should fix the error I'm getting back after trying to run it. The code is meant to encode and decode text files using c strings.

Here is the source code:

#include <iostream>
#include <fstream>
#include <string>
#include <stdafx.h>
using namespace std;

void mapitE(string,char[]);
void mapitD(string,char[]);
void encryptdecrypt(const string,const char[],int,string&);
int main()
{
string ende[]={"encrypt","decrypt"},buffer,key,newbuffer="";
char filename[80],enmap[128],demap[128],again;
int i,maplength;
ofstream out;
ifstream in;
int choice;
do
{
cout<>choice;
while(choice2)
{
cout<<"invalid choice\n";
cout<>choice;
}

cout<<"Enter name of your file to "<<ende[choice-1]<>filename;
in.open(filename);
if(in.fail())
{
cout<<"input file did not open please check it\n";
system("pause");
return 1;
}

cout<>filename;
out.open(filename);
cout<>key;
if(key.length()>128)
{
cout<<"key too long\n";
cout<>key;
}

maplength=key.length();

if(choice==1) {
mapitE(key,enmap);
}
else {
mapitD(key,demap);
}
getline(in,buffer);

while(in)
{
if(choice==1) {
encryptdecrypt(buffer,enmap,maplength,newbuffer);
}
else {
encryptdecrypt(buffer,demap,maplength,newbuffer);
}
out<<newbuffer;
newbuffer.erase(0);
getline(in,buffer);

}
out.close();
in.close();
in.clear();
out.clear();
newbuffer.erase(0);
cout<>again;
} while(toupper(again)=='Y');
return 0;
}
void encryptdecrypt(const string buffer,const char map[],int len,string& newbuffer)
{
int i=0;
char t,code;
for(i=0;i<buffer.length();i++)
{
cout<<buffer<<" "<<i<<endl;
if(isalpha(buffer))
{
if(islower(buffer)) {
code='a';
}
else {
code='A';
}
t=buffer-code;
t=t+map[i%len];
t=t%26;
t=t+code;
cout<<i<<" "<< buffer<<" "<<map[i%len]<<" "<<t<<endl;
newbuffer.push_back(t);
}

else {
newbuffer.push_back(buffer);
}
}
newbuffer.push_back('\n');
}
void mapitE(string key,char map[])
{
int i;
for(i=0;i<key.length();i++)
map=key-'a';
}
void mapitD(string key,char map[])
{
int i;
for(i=0;i<key.length();i++)
map=26-(key-'a');
}

The issue with this is when I try to compile it I get this back in the output box.

1>------ Build started: Project: ConsoleApplication8, Configuration: Debug Win32 ------
1> Source.cpp
1>\\acad.dvuadmin.net\sce\homedir\d40048587\documents\visual studio 2012\projects\consoleapplication8\consoleapplication8\source.cpp(4): fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I'm using visual studios 2010 for this code and would appreciate any help I can get, as I am sure this one little error is the only thing keeping my code from running perfectly.
@SneakyLizard

The answer to your problem, is actually an easy one. #include <stdafx.h> MUST be the first include, so put it at the top of your code. The program should run afterwards, with no problems.
If you want pre-compiled headers, change this line:
#include <stdafx.h>

To this:
#include "stdafx.h"

If you don't want pre-compiled headers, simply remove that line.
Topic archived. No new replies allowed.