i have done this porgram that sorts alphabets in ascending or descending order,
when compiling this program, i only get one error saying
fatal error c1004 : unexpected end of file found.
here is the code:
Code:
#include <iostream>
#include <cctype>
#include <cstdlib>
int main()
{
char strspace[50]; /* enough ?? */
printf("Enter a string ");
scanf("%s",strspace);
printf("The string was >>%s<<\n",strspace);
using namespace std;
{ char ans;
do
{
//Declarations
char string[21];
char decrypt;
int i;
//Get string from user
cout<<"Enter a string no longer than 20 characters long:"<<endl;
cin.get(string,20);
cin.ignore(80,'\n');
cout<<endl;
//encrypt
for(int a = 0; a < strlen(string); a++)
{
if(isupper (string[a]))
i = (int) 'A';
else if(islower ((int) string[a]))
i = (int) 'a';
if(isalpha(string[a]))
{
string[a] = string[a] - i;
string[a] = string[a] + 1;
string[a] = string[a] % 26;
string[a] = string[a] + i;
}
}
//Ask for decrypt
cout<<"Would you like to decrypt this string? (y,n) ";
cin>>decrypt;
cout<<endl;
//Decrypt and output
if(decrypt != 'n') //decrypt?
{
for(int j = 0; j < strlen(string); j++) //decrypt individual characters
{
if(isalpha(string[j]))
{
if(isupper (string[j]))
i = (int) 'A';
else if(islower ((int) string[j]))
i = (int) 'a';
string[j] = string[j] - i;
string[j] = string[j] - 1;
if(string[j] < 0)
string[j] = 25;
string[j] = string[j] + i;
}
}
cout<<endl<<endl<<"The decrypted string is: "<<string<<endl<<endl;
}
//Run again code
cout<< "Would you like to run this program again? (y,n) ";
cin>>ans;
cin.sync();
}while(ans != 'n');
return 0;}
}
can anyone investigate what the error is?
thanks