I'm trying to read input and store it into a character array. It works up to the point that I enter the stream of characters and press enter. Then the program breaks, and a windows pops up and says "Stack Around Input is Corrupted." I'm wondering why this runtime error comes up.
#include "stdafx.h"
#include "iostream"
#include "windows.h"
usingnamespace std;
int main()
{
int i=0; //so far this does nothing
char input [5];
//intro
cout<<"Welcome to the Text/Phone Number Converter!\n";
cout<<"This program will convert seven characters of text into their numeric equivalent. \nNumbers will be left as-is.\n";
Sleep(2000);
cout<<"Please enter your desired string: \n";
cin>>input[1]>>input[2]>>input[3]>>input[4]>>input[5]>>input[6]>>input[7];
cout<<input[1]<<input[2]<<input[3]<<input[4]<<input[5]<<input[6]<<input[7];
cout<<"Please enter any key to continue.";
cin.get();
return 0;
}
EDIT: I found the error. I created the character array for 5 characters, but tried to get seven. My bad.