Hello people of the internet. I am currently learning how to program in c++ and I am having trouble with a program. This program is supposed to take in a string and write it out again wtih the ascii ordinance having a plus two i.e a = c or s = u. Whenever I run the program though the first character is taken in as a space and thus prints the character with the ascii ordinance of two. I am still pretty new to c++ so my code is pretty inefecient and all-around bad. Here is my code.
// ActivitySixPointOne.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include <string>
#include <iostream>
using namespace std;
char Character;
string SubString;
int y;
string GetString()
{
string SString;
cout << "Please enter your string.\n";
cin >> SString;
return SString;
}
int _tmain(int argc, _TCHAR* argv[])
{
string TString;
int StringLength;
StringLength = 0;
TString = GetString();
StringLength = TString.length();
cout << "Your encoded string is.\n";
for (int x = 1; x <= StringLength;x++)
{
y = x - 1;
SubString = TString.substr(y, y);
Character = SubString[0];
Character = _putch(Character + 2);
}
cout << "\n";
system("pause");
return0;
}