Try this.
#include
#include
using namespace std;
This should remove the error in first line and
"//getline (cin, input); // Error Given: " 'getline': identifier not found "
I dont think functioin get is declared in string or iostream. Thats y its giving undeclared identifier error.
dilip.mathews
Junior Poster in Training
89 posts since Jun 2006
Reputation Points: 16
Solved Threads: 3
I am also getting the memory access error when i ran ur prgrm.
I think the problem is with the way in which u have declarec the string "input".
For debugging purpose i have made a small change in the programm and tried as shoen below. It worked.
void encrypt()
{
char* input = new char[100];
strcpy(input,"Hello");
char activeChar=0;
int done=0;
std::cout << "enter text (max 64 characters):\n";
//getline(cin,(string)input);
This is the only change I hav emade. Now the encrypt fun is working.
Please consult with somebody else also. I am quite not sure how the string class i implemented internally.
dilip.mathews
Junior Poster in Training
89 posts since Jun 2006
Reputation Points: 16
Solved Threads: 3
Waht does 'cin.ignore' do???
dilip.mathews
Junior Poster in Training
89 posts since Jun 2006
Reputation Points: 16
Solved Threads: 3
I have modified ur encrypt as shoen below. I dont think there is any need for "ignore".
void encrypt()
{
std::string input;
char activeChar=0;
int done=0;
std::cout << "enter text:\n";
std::getline(std::cin, input);
while(!done)
{
/* special checks */
if(input[activeChar]=='\0') // if character is null, end loop
{done=1;
input[activeChar]= '\0';
break;
}
if(input[activeChar]==32) // if character is a space, move to next character and skip loop
{
activeChar++;
continue;
}
/* encryption process */
input[activeChar]+=1; // Increase the decimal value of the character by 1
activeChar++; // Move to next character
}
std::cout << "encrypted:" << input << '\n' << '\n';
}
dilip.mathews
Junior Poster in Training
89 posts since Jun 2006
Reputation Points: 16
Solved Threads: 3
Use code tags when posting code.
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115