Can someone tell me how to clear the final two errors I am rcving on this?
Errors:
error C2365: 'palDrome' : redefinition; previous definition was a 'data variable'
error C2601: 'palDrome' : local function definitions are illegal
Code Tags added by Kermi3Code://Program description: Palindrome #include <iostream> #include <string.h> #include <windows.h> #include <stdio.h> using namespace std; class Stack { int x; int OnTop; int size; char* S; public: Stack(int SizeOfStack = 100); ~Stack(); bool StackIsFull(void); bool StackIsEmpty(void); void Push(char x); char Pop(void); } //contructor Stack(); bool Stack::StackIsFull(void) { return OnTop >= size -1; } bool Stack::StackIsEmpty(void) { return OnTop <0; } void Stack::Push(char x) { S[++OnTop] = x; } char Stack::Pop(void) { return S[OnTop--]; } //main function int main() { //use to declare the variables for program HANDLE hInputFile; HANDLE hInputFileMap; PVOID pvInputFile; DWORD dwInputFileSize = 0; char inputFileName [255]; HANDLE hOutputFile; HANDLE hOutputFileMap; PVOID pvOutputFile; DWORD dwOutputFileSize = 0; char outputFileName[255]; DWORD dwErr; char pDrome[15]; int palinDrome; bool palDrome; int i; //menu prompt for user cout<<"-----------------------------------------------------------------"; cout<<" Please enter the Input file name for the origin: "; cin>>inputFileName; cout<<endl; cout<<endl; cout<<"-----------------------------------------------------------------"; cout<<"-----------------------------------------------------------------"; cout<<" Please enter the Output file name for the destination: "; cin>>outputFileName; cout<<endl; cout<<endl; cout<<"-----------------------------------------------------------------"; //used to create a handle for the input file hInputFile = CreateFile(inputFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hInputFile == INVALID_HANDLE_VALUE) { dwErr = GetLastError(); cout<<"Error occured. The current error number is "; cin>>dwErr; cout<<"."; cout<<endl; cout<<"The input file could not be opened due to error."; cout<<endl; cout<<endl; return(FALSE); } //used to create handle for the input file mapping hInputFileMap = CreateFileMapping(hInputFile, NULL, PAGE_READONLY, 0, 0, NULL); if (hInputFileMap == NULL) { dwErr = GetLastError(); cout<<"Error occured. The current error number is "; cin>>dwErr; cout<<"."; cout<<endl; cout<<"The input file map could not be viewed."; CloseHandle(hInputFile); return(FALSE); } //used tp create a mapped view of the input file pvInputFile = MapViewOfFile(hInputFileMap, FILE_MAP_READ, 0, 0, 0); if (pvInputFile == NULL) { dwErr = GetLastError(); cout<<"Error occured. The current error number is "; cin>>dwErr; cout<<"."; cout<<endl; cout<<"The input file map could not be viewed."; cout<<endl; CloseHandle(hInputFileMap); CloseHandle(hInputFile); return (FALSE); } //used to determine the size of the input file dwInputFileSize = GetFileSize(hInputFile, NULL); PSTR pchANSI = (PSTR) pvInputFile; //used to determine the size for the output file for (i = 0; i < (int)dwInputFileSize; i++) { palinDrome = (int)pchANSI[i]; itoa(palinDrome, pDrome, 15); dwOutputFileSize = dwOutputFileSize + strlen(pDrome) + 1; } //used to get rid of the last space dwOutputFileSize = dwOutputFileSize - 1; //used to create a handle to the output file hOutputFile = CreateFile(outputFileName, GENERIC_WRITE | GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); if (hOutputFile == INVALID_HANDLE_VALUE) { dwErr = GetLastError(); dwErr = GetLastError(); cout<<"Error occured. The current error number is "; cin>>dwErr; cout<<"."; cout<<endl; cout<<"The output file could not be made due to error."; cout<<endl; cout<<endl; UnmapViewOfFile(pvInputFile); CloseHandle(hInputFileMap); CloseHandle(hInputFile); return(FALSE); } //used to create a handle to the output file mapping hOutputFileMap = CreateFileMapping(hOutputFile,NULL, PAGE_READWRITE, 0, dwOutputFileSize, NULL); if (hOutputFileMap == NULL) { dwErr = GetLastError(); cout<<"Error occured. The current error number is "; cin>>dwErr; cout<<"."; cout<<endl; cout<<"The output file mapping could not be opened due to error."; cout<<endl; cout<<endl; UnmapViewOfFile(pvInputFile); CloseHandle(hOutputFile); CloseHandle(hInputFileMap); CloseHandle(hInputFile); return(FALSE); } //usd to map a view of the output file pvOutputFile = MapViewOfFile(hOutputFileMap, FILE_MAP_WRITE, 0, 0, 0); if (pvOutputFile == NULL) { dwErr = GetLastError(); cout<<"Error occured. The current error number is "; cin>>dwErr; cout<<"."; cout<<endl; cout<<"The error has caused the map view to be unavailable."; cout<<endl; cout<<endl; UnmapViewOfFile(pvInputFile); CloseHandle(hOutputFileMap); CloseHandle(hOutputFile); CloseHandle(hInputFileMap); CloseHandle(hInputFile); return(FALSE); } PSTR pchASCII = (PSTR) pvOutputFile; //is the word a palindrome? bool palDrome(char* S) { Stack S(strlen(c) * sizeof(char)); for (int i = 0; x < strlen(c); i++) S.Push(c[i]); int i = 0; while (!S.StackIsEmpty()) if (c[i] != S.Pop()) return false; return true; } }



LinkBack URL
About LinkBacks



) corner of your original post.