Hi I was wondering why I have an error in this program every time I try to do a long encryption. For example, encrypting an ebook or long document. I only occurs in the advanced encryption and advanced decryption functions. I'm pretty sure it has something to do with memory or access violation, according to the code, but a point in the direction to fix it would be greatly appreciated.
Thanks.

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;

	char path1[256], path2[256]; 
	int EnORDe;
	char a,b;
	char newline='\r\n';
	int pavalue[32];
void Sencrypt();
void Sdecrypt();
void passcode(int *pvalue);
void aencrypt(int *code);
void adecrypt(int *code);

int main ()
{
	cout << "what is the path to the text file: ";
	cin.getline(path1,257);
	cout << "where do you want the new text file: ";
	cin.getline(path2,257);
	cout << "would you like to encrypt or decrypt a file(1 or 2)"<<"\n";
	cout <<"advance encrypt (3) and advanced decrypt (4): ";
		cin>>EnORDe;
		cout<<newline;
	if(EnORDe == 1)
	{
		Sencrypt();
	}
	else if(EnORDe == 2)
	{
		Sdecrypt();
	}
	else if(EnORDe == 3)
	{
		passcode(pavalue);
		aencrypt(pavalue);
	}
	else if(EnORDe == 4)
	{
		passcode(pavalue);
		adecrypt(pavalue);
	}
	else
	{
		cout<<"ERROR!!!"<<'\n';
		cout<<"Please enter one of the numbers listed"<<'\n';
	}
	
system("PAUSE");

return 0;
}
//simple encryption
void Sencrypt()
	{

	ifstream text(path1);
	a=('a'+'A'-'b')/'5';
	ofstream myfile;
  myfile.open (path2);
	while(text.get(b))
	{	
		b+=a;
		myfile <<b;
	}
	myfile.close();

	return;
	}
//simple decryption
void Sdecrypt()
{
	
	
	ifstream text(path1);
	a=('a'+'A'-'b')/'5';
	ofstream myfile;
	myfile.open (path2);
	while(text.get(b))
	{
		b-=a; 
		myfile <<b;

	}
			myfile.close();
	return;
}


//reads passcode for value of array to use
void passcode(int *pvalue)
{
	char pword[32];
	cout<< "Enter passcode(up to 32 characters): ";
	cin>>pword;
	cout<<pword<<"\n";
		
	int i;

	for(i=0; pword[i]; i++)
{	

	// Lower Case letters
		if(pword[i]=='a' ||pword[i]== 'p')
	{	
			pvalue[i]=0;
		}
		else if(pword[i]=='b' ||pword[i]== 'q')
		{	
			pvalue[i]=1;
		}
		else if(pword[i]=='c' ||pword[i]== 'r')
		{	
			pvalue[i]=2;
		}
		else if(pword[i]=='d' ||pword[i]== 's')
		{	
			pvalue[i]=3;
		}
		else if(pword[i]=='e' ||pword[i]== 't')
		{	
			pvalue[i]=4;
		}
		else if(pword[i]=='f' ||pword[i]== 'u')
		{	
			pvalue[i]=5;
		}
		else if(pword[i]=='g' ||pword[i]== 'v')
		{	
			pvalue[i]=6;
		}
		else if(pword[i]== 'h' ||pword[i]== 'w')
		{	
			pvalue[i]=7;
		}
		else if(pword[i]=='i' ||pword[i]== 'x')
		{	
			pvalue[i]=8;
		}
		else if(pword[i]=='j' ||pword[i]== 'y')
		{	
			pvalue[i]=9;
		}
		else if(pword[i]=='k' ||pword[i]== 'z')
		{	
			pvalue[i]=10;
		}
		else if(pword[i]=='l')
		{	
			pvalue[i]=11;
		}
		else if(pword[i]=='m')
		{	
			pvalue[i]=12;
		}
		else if(pword[i]=='n')
		{	
			pvalue[i]=13;
		}
		else if(pword[i]=='o')
		{	
			pvalue[i]=14;
		}


		// Capital letters
		else if(pword[i]=='A' ||pword[i]== 'B')
	{	
			pvalue[i]=15;
		}
		else if(pword[i]=='C' ||pword[i]== 'D')
		{	
			pvalue[i]=16;
		}
		else if(pword[i]=='E' ||pword[i]== 'F')
		{	
			pvalue[i]=17;
		}
		else if(pword[i]=='G' ||pword[i]== 'H')
		{	
			pvalue[i]=18;
		}
		else if(pword[i]=='I' ||pword[i]== 'J')
		{	
			pvalue[i]=19;
		}
		else if(pword[i]=='K' ||pword[i]== 'L')
		{	
			pvalue[i]=20;
		}
		else if(pword[i]=='M' ||pword[i]== 'N')
		{	
			pvalue[i]=21;
		}
		else if(pword[i]== 'O' ||pword[i]== 'P')
		{	
			pvalue[i]=22;
		}
		else if(pword[i]=='Q' ||pword[i]== 'R')
		{	
			pvalue[i]=23;
		}
		else if(pword[i]=='S' ||pword[i]== 'T')
		{	
			pvalue[i]=24;
		}
		else if(pword[i]=='U' ||pword[i]== 'V')
		{	
			pvalue[i]=25;
		}
		else if(pword[i]=='W')
		{	
			pvalue[i]=26;
		}
		else if(pword[i]=='X')
		{	
			pvalue[i]=27;
		}
		else if(pword[i]=='Y')
		{	
			pvalue[i]=28;
		}
		else if(pword[i]=='Z')
		{	
			pvalue[i]=29;
		}
		else if(pword[i]==' ')
		{	
			pvalue[i]=30;
		}

		//NUMBERS
		else
		{	
			pvalue[i]=31;
		}

	}
 return;
}

//advanced encryption
void  aencrypt(int *code) 
{
	char codearray[32]={'j','b','m','o','O','s','e','t','i','w','z','Z','6','2',
		'7','x','p','K','1','d','r','M','n','k','q','I','H','v','T','U','0'};
	int i=0;
	ifstream text(path1);
	ofstream myfile;
	myfile.open (path2);
	while(text.get(b))
	{
		if(i%2==1)
		{b+=codearray[pavalue[i]];}
		else if(i%2==0)
		{b-=codearray[pavalue[i]];}
		myfile <<b;
		if(i>=sizeof(codearray))
		{i=0;}
		i++;
	}
	myfile.close();
	return;
}

//advanced decryption
void  adecrypt(int *code) 
{
	char codearray[32]={'j','b','m','o','O','s','e','t','i','w','z','Z','6','2',
		'7','x','p','K','1','d','r','M','n','k','q','I','H','v','T','U','0'};
	int i=0;
	ifstream text(path1);
	ofstream myfile;
	myfile.open (path2);
	while(text.get(b))
	{
		if(i%2==1)
		{b-=codearray[pavalue[i]];}
		else if(i%2==0)
		{b+=codearray[pavalue[i]];}
		myfile <<b;
		if(i>=sizeof(codearray))
		{i=0;}
		i++;
	}
	myfile.close();
	return;
}

You need to have room for '\0'. Change

int EnORDe;
char a,b;
char newline='\n';  // <--- Changed, was getting a warning can't have two chars set to one char
int pavalue[33];   // <--- 32 to 33 <--------------LOOK HERE
//---------------
//reads passcode for value of array to use
void passcode(int *pvalue)
{
  char pword[33] = {0};  // <------ 32 to 33 <----- LOOK HERE EDIT added the = {0} looked like it worked
  cout<< "Enter passcode(up to 32 characters): ";
  cin>>pword;
  cout<<pword<<"\n";

  int i;
  for(i=0; i< strlen(pword); i++) // <---- use strlen<--------------LOOK HERE

I think that is all I changed. Didn't crash and it did work. I only tested option 3 and 4

You need to have room for '\0'. Change

int EnORDe;
char a,b;
char newline='\n';  // <--- Changed, was getting a warning can't have two chars set to one char
int pavalue[33];   // <--- 32 to 33 <--------------LOOK HERE
//---------------
//reads passcode for value of array to use
void passcode(int *pvalue)
{
  char pword[33] = {0};  // <------ 32 to 33 <----- LOOK HERE EDIT added the = {0} looked like it worked
  cout<< "Enter passcode(up to 32 characters): ";
  cin>>pword;
  cout<<pword<<"\n";

  int i;
  for(i=0; i< strlen(pword); i++) // <---- use strlen<--------------LOOK HERE

I think that is all I changed. Didn't crash and it did work. I only tested option 3 and 4

While that does fix some warnings and such it doesn't fix the major problem I had. I was trying to encrypt a larger file like a book and while it looks like the advanced encryption works as the files come out with relatively similar size the advanced decryption only decodes about the first few lines and I that's what I'm trying to fix. Did you not have that problem?
Thanks for the help so far though. :)

After encryption and decryption, it's hard to read back.. what you do is that for each line, encode/decode using base64 as if u don't, sometimes the characters won't be read back exactly how they were..

Had this happen to me before.. so I just used base64 or hexadecimal for each char.. and it fixed it..

Dunno if that'll help u though.

With the changes I made it worked for me. Here is a run with a 454 MB tar file that I encrypted and decrypted, then ran tar tvf to see if there were error and not errors. Is ~1/2 Gig as large as your file?

$ ls -l my*.tar
-rw-r--r--@ 1 xx  xx  454612480 Dec 19  2010 mysql-5.5.8-osx10.6-x86_64.tar
$ tar tvf mysql-5.5.8-osx10.6-x86_64.tar | wc -l
    6577
$ ../code/c++/a.out
what is the path to the text file: mysql-5.5.8-osx10.6-x86_64.tar
where do you want the new text file: t.en
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 3

Enter passcode(up to 32 characters): 12345678901234567890123456789012
12345678901234567890123456789012
$ tar tvf t.en
tar: Unrecognized archive format: Inappropriate file type or format
tar: Error exit delayed from previous errors.
$ ../code/c++/a.out
what is the path to the text file: t.en
where do you want the new text file: mysql.tar
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 4

Enter passcode(up to 32 characters): 12345678901234567890123456789012
12345678901234567890123456789012
$ tar tvf mysql.tar | wc -l
    6577
$

The reason that the program is working for you is because essentially you aren't using the advanced encryption because numbers all have the same value it's just added or subtracted if you try with another password using letters it doesn't work. At least I think that the problem has something to do with the different values caused by the letters.

I do think I see one more issue

void  aencrypt(int *code)
// ...
       i++;     // <--- Should inc it first then check.         
       if(i>=sizeof(codearray))
         {i=0;}
// ....
void  adecrypt(int *code)
       i++;     // <--- Should inc it first then check.         
       if(i>=sizeof(codearray))
         {i=0;}
$ ../code/c++/a.out
what is the path to the text file: mysql-5.5.8-osx10.6-x86_64.tar
where do you want the new text file: t.en
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 3

Enter passcode(up to 32 characters): QAWSEDFFgthyjuij445&^$#dd5
QAWSEDFFgthyjuij445&^$#dd5
$ tar tvf t.en
tar: Unrecognized archive format: Inappropriate file type or format
tar: Error exit delayed from previous errors.
$ ../code/c++/a.out
what is the path to the text file: t.en
where do you want the new text file: my.tar
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 4

Enter passcode(up to 32 characters): QAWSEDFFgthyjuij445&^$#dd5
QAWSEDFFgthyjuij445&^$#dd5
$ tar tvf my.tar | wc -l
    6577

If this works you might want to use a getline with a std::string so you can check the size against the limit of 32. Currently if someone enters 55 chars, it would be overwriting memory on the stack which would be bad.

Sorry I'm still having the same problem. I've made all the changes you've made so far but unfortunately it hasn't fix the fact the long files are missing almost the entire file by the time I decrypt them. I get four lines out of the .txt book I'm testing this on. I attached the text file I'm testing maybe you'll see what I mean if you try encrypting it and decrypting it.
Sorry for causing so much trouble.

Works for me. See if there is something different.

$ ls -tlr doc1.txt 
-rw-r--r--@ 1 x  x  662210 Feb 29 16:58 doc1.txt
$ ../code/c++/a.out
what is the path to the text file: doc1.txt
where do you want the new text file: doc.enc
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 3

Enter passcode(up to 32 characters): QAWSedwsedRFTHGYU5678
QAWSedwsedRFTHGYU5678
$ ../code/c++/a.out
what is the path to the text file: doc.enc
where do you want the new text file: doc1.denc.txt
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 4

Enter passcode(up to 32 characters): QAWSedwsedRFTHGYU5678
QAWSedwsedRFTHGYU5678
$ wc -l doc1.txt 
    3068 doc1.txt
$ wc -l doc1.denc.txt 
    3068 doc1.denc.txt

Here is your code

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;

	char path1[256], path2[256]; 
	int EnORDe;
	char a,b;
	char newline='\n';
	int pavalue[33];
void Sencrypt();
void Sdecrypt();
void passcode(int *pvalue);
void aencrypt(int *code);
void adecrypt(int *code);

int main ()
{
	cout << "what is the path to the text file: ";
	cin.getline(path1,257);
	cout << "where do you want the new text file: ";
	cin.getline(path2,257);
	cout << "would you like to encrypt or decrypt a file(1 or 2)"<<"\n";
	cout <<"advance encrypt (3) and advanced decrypt (4): ";
		cin>>EnORDe;
		cout<<newline;
	if(EnORDe == 1)
	{
		Sencrypt();
	}
	else if(EnORDe == 2)
	{
		Sdecrypt();
	}
	else if(EnORDe == 3)
	{
		passcode(pavalue);
		aencrypt(pavalue);
	}
	else if(EnORDe == 4)
	{
		passcode(pavalue);
		adecrypt(pavalue);
	}
	else
	{
		cout<<"ERROR!!!"<<'\n';
		cout<<"Please enter one of the numbers listed"<<'\n';
	}
	
system("PAUSE");

return 0;
}
//simple encryption
void Sencrypt()
	{

	ifstream text(path1);
	a=('a'+'A'-'b')/'5';
	ofstream myfile;
  myfile.open (path2);
	while(text.get(b))
	{	
		b+=a;
		myfile <<b;
	}
	myfile.close();

	return;
	}
//simple decryption
void Sdecrypt()
{
	
	
	ifstream text(path1);
	a=('a'+'A'-'b')/'5';
	ofstream myfile;
	myfile.open (path2);
	while(text.get(b))
	{
		b-=a; 
		myfile <<b;

	}
			myfile.close();
	return;
}


//reads passcode for value of array to use
void passcode(int *pvalue)
{
	char pword[33] = {0};
	cout<< "Enter passcode(up to 32 characters): ";
	cin>>pword;
	cout<<pword<<"\n";
		
	int i;

	for(i=0; i< strlen(pword); i++)
{	

	// Lower Case letters
		if(pword[i]=='a' ||pword[i]== 'p')
	{	
			pvalue[i]=0;
		}
		else if(pword[i]=='b' ||pword[i]== 'q')
		{	
			pvalue[i]=1;
		}
		else if(pword[i]=='c' ||pword[i]== 'r')
		{	
			pvalue[i]=2;
		}
		else if(pword[i]=='d' ||pword[i]== 's')
		{	
			pvalue[i]=3;
		}
		else if(pword[i]=='e' ||pword[i]== 't')
		{	
			pvalue[i]=4;
		}
		else if(pword[i]=='f' ||pword[i]== 'u')
		{	
			pvalue[i]=5;
		}
		else if(pword[i]=='g' ||pword[i]== 'v')
		{	
			pvalue[i]=6;
		}
		else if(pword[i]== 'h' ||pword[i]== 'w')
		{	
			pvalue[i]=7;
		}
		else if(pword[i]=='i' ||pword[i]== 'x')
		{	
			pvalue[i]=8;
		}
		else if(pword[i]=='j' ||pword[i]== 'y')
		{	
			pvalue[i]=9;
		}
		else if(pword[i]=='k' ||pword[i]== 'z')
		{	
			pvalue[i]=10;
		}
		else if(pword[i]=='l')
		{	
			pvalue[i]=11;
		}
		else if(pword[i]=='m')
		{	
			pvalue[i]=12;
		}
		else if(pword[i]=='n')
		{	
			pvalue[i]=13;
		}
		else if(pword[i]=='o')
		{	
			pvalue[i]=14;
		}


		// Capital letters
		else if(pword[i]=='A' ||pword[i]== 'B')
	{	
			pvalue[i]=15;
		}
		else if(pword[i]=='C' ||pword[i]== 'D')
		{	
			pvalue[i]=16;
		}
		else if(pword[i]=='E' ||pword[i]== 'F')
		{	
			pvalue[i]=17;
		}
		else if(pword[i]=='G' ||pword[i]== 'H')
		{	
			pvalue[i]=18;
		}
		else if(pword[i]=='I' ||pword[i]== 'J')
		{	
			pvalue[i]=19;
		}
		else if(pword[i]=='K' ||pword[i]== 'L')
		{	
			pvalue[i]=20;
		}
		else if(pword[i]=='M' ||pword[i]== 'N')
		{	
			pvalue[i]=21;
		}
		else if(pword[i]== 'O' ||pword[i]== 'P')
		{	
			pvalue[i]=22;
		}
		else if(pword[i]=='Q' ||pword[i]== 'R')
		{	
			pvalue[i]=23;
		}
		else if(pword[i]=='S' ||pword[i]== 'T')
		{	
			pvalue[i]=24;
		}
		else if(pword[i]=='U' ||pword[i]== 'V')
		{	
			pvalue[i]=25;
		}
		else if(pword[i]=='W')
		{	
			pvalue[i]=26;
		}
		else if(pword[i]=='X')
		{	
			pvalue[i]=27;
		}
		else if(pword[i]=='Y')
		{	
			pvalue[i]=28;
		}
		else if(pword[i]=='Z')
		{	
			pvalue[i]=29;
		}
		else if(pword[i]==' ')
		{	
			pvalue[i]=30;
		}

		//NUMBERS
		else
		{	
			pvalue[i]=31;
		}

	}
 return;
}

//advanced encryption
void  aencrypt(int *code) 
{
	char codearray[32]={'j','b','m','o','O','s','e','t','i','w','z','Z','6','2',
		'7','x','p','K','1','d','r','M','n','k','q','I','H','v','T','U','0'};
	int i=0;
	ifstream text(path1);
	ofstream myfile;
	myfile.open (path2);
	while(text.get(b))
	{
		if(i%2==1)
		{b+=codearray[pavalue[i]];}
		else if(i%2==0)
		{b-=codearray[pavalue[i]];}
		myfile <<b;
		i++;
		if(i>=sizeof(codearray))
		{i=0;}
	}
	myfile.close();
	return;
}

//advanced decryption
void  adecrypt(int *code) 
{
	char codearray[32]={'j','b','m','o','O','s','e','t','i','w','z','Z','6','2',
		'7','x','p','K','1','d','r','M','n','k','q','I','H','v','T','U','0'};
	int i=0;
	ifstream text(path1);
	ofstream myfile;
	myfile.open (path2);
	while(text.get(b))
	{
		if(i%2==1)
		{b-=codearray[pavalue[i]];}
		else if(i%2==0)
		{b+=codearray[pavalue[i]];}
		myfile <<b;
		i++;
		if(i>=sizeof(codearray))
		{i=0;}
	}
	myfile.close();
	return;
}

My code is the exact same but when I open the decrypted file only 4 lines of text are in there instead of the entire document.

Run it in a debugger or put some print statements in the code to see when it stops reading. Does the encrypt process all of the data? Put in a counter to see. And the same for the decrypt. Compare that number to the size of the file, they should match.

I've found that the problem doesn't lie in the code it actually works for me if I switch the decryption and encryption method for my txt file but that just means their is a different problem not having to do with the written code. I think I'm not accounting for something in the text file. it runs 659142 times with the encryption originally, before I switched the encrypt and decrypt, but only 134 times with the decryption. Since that is just changing the signs I don't think it would cause such an error maybe I'm causing a null ASCII value in the program and it causes my while(text.get(b)) to be false before the program is over? Is that at all logical?

Whatever you are doing to the data shouldn't cause while(text.get(b)) to be false before the EOF. What is the "passcode(up to 32 characters)" that you are using? I would like to test exactly what your are to see if I can get it to happen for me.
That said, what is the value at char 134 (0x86) in your encrypt file. You can use hexdump to see.

$ hexdump -C ../../Downloads/doc.enc | more
00000000  2a 98 fb b9 f2 bf e0 b4  03 8f e4 99 d4 51 64 61  |*............Qda|
00000010  c1 57 61 72 6c d9 f9 d5  a3 74 ea d2 fb 8a fa cf  |.Warl....t......|
00000020  02 e7 26 91 19 de 03 db  16 d3 b5 b4 03 a4 ef c3  |..&.............|
00000030  2c 74 72 61 67 cf c4 77  a0 ab 03 d3 08 cb 04 de  |,trag..w........|
00000040  fd d9 e4 91 08 d0 fe db  20 d2 00 6b fe 97 ef c8  |........ ..k....|
00000050  1f 65 20 53 61 de 0b d7  f8 dc ff cb c2 8a 08 cf  |.e Sa...........|
00000060  fa e4 1d d5 d1 d1 ed d2  1c e6 f6 bd f3 a4 ef ba  |................|
00000070  29 6f 6d 20 74 d2 fb 8a  0b d8 fb e2 06 cf f9 de  |)om t...........|
00000080  fa dc d8 d6 29 df [B][U]f8[/U][/B] de  24 d8 04 b9 af a0 35 74  |....)...$.....5t|

For the key I used it was 0xf8.

I used zKidMKt4 and it hangs on the word explosion right after printing the 's'. The while goes false for some reason and it then it goes to myfile.close and return. So I deleted the word "explosion" and it read until the 614th character. The program hung right before and 'i' again in the word "reality". For some reason the while is coming back false at those values. So far all I've determined is that the value from the text file has something to do with it and I would bet the value of the password.
Thanks for all the help.

Your code is working for me. Do you have enough disk space?

$ ./a.out
what is the path to the text file: doc1.txt
where do you want the new text file: doc1.en
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 3

Enter passcode(up to 32 characters): zKidMKt4
zKidMKt4

$ ./a.out
what is the path to the text file: doc1.en
where do you want the new text file: doc1.de.txt
would you like to encrypt or decrypt a file(1 or 2)
advance encrypt (3) and advanced decrypt (4): 4

Enter passcode(up to 32 characters): zKidMKt4
zKidMKt4

$ [U][B]diff doc1.txt doc1.de.txt [/B][/U]  [B]<------ No difference![/B]

$ ls -l doc1*
[B]-rw-rw-r-- 1 xx xx 662210 Mar  1 23:46 doc1.de.txt
-rw-rw-r-- 1 xx xx 662210 Mar  1 23:45 doc1.en
-rw-r--r-- 1 xx xx 662210 Mar  1 23:38 doc1.txt[/B]

I have 300+ gigabytes of disc space so that isn't the issue. I'm completely out of ideas as to what to do with it. You really have nothing wrong with it but my program hangs on "i" for some reason.

Also in the zKidMKt4 the "t" is what hangs on the 'i' in the text document.

Add theses to both functions right after the while loop, just to see what it prints.

cout << "aencrypt:  good(" << text.good() << ") fail("
     << text.fail() << ") badbit("
     << text.bad() << ") eofbit("
     << text.eof() << ")" << endl; 
// And
cout << "adecrypt:  good(" << text.good() << ") fail("
    << text.fail() << ") badbit(" 
    << text.bad() << ") eofbit(" 
    << text.eof() << ")" << endl;

Could you post just your aencrypt and adecrypt functions again. Just them.

The bits all read good but it stops at 134.

correct me if I'm wrong but isn't that more for linux? I'm using windows 7.

Also if I place the bit checker outside of the while loop it gives me a fail(1) and .EOF(1) at the value of 134 durring decryption.

Just curuois, what is your compiler and OS?

If it is an issue with corruption of the ifstream object, for whatever reason, you can move the ifstream text off of the stack to see if it makes a difference. Just for debugging, make the ifstream text a global and see what happens. If it works then the object is getting corrupted on the stack in the decrypt function.
Try that first and if it still doesn't work then try changing file I/O to C rather than C++ iostream.

Just curuois, what is your compiler and OS?

Windows 7 and I've used vc++, devc++, and code::blocks. does the same thing in each. I'll try making the iostream a global in the next couple days due to some high school inconvenience.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.