this prog. is supposed to demonstrate a strcpy error...however im getting an error and it wont run....once again im suing a dev c++ bloodshed compiler.
and heres my code....once again i know it has a strcpy error thats the reason for writting the program..to demonstrate a char array overflow.
strerror.cpp
#include <iostream>
#include <string>
int main()
{
char student_name[21] = "Brandon Adkins"; //declare four
char city[] = "Lubbock";
char state[3] = "TX";
char ZIP_code[11] = "79413-3640";
cout << student_name << '\n'; //display the strings
cout << city << '\n';
cout << state << '\n';
cout << ZIP_code << '\n';
strcpy(state,"California"); //copy a string that is too long
//into the state char. array.
cout << student_name << '\n'; //display the strings again
cout << city << '\n'; //showing the overwritten array.
cout << state << '\n';
cout << ZIP_code << '\n';
cin.get();
cin.get();
return 0;
}
so wiser ones....whats the problem now....
(side not....dev compiler is sooo annoying...i messed around with a visual studios compiler and it was more user friendly....)
im going out of a book here but unfortunately it doesnt support devs picky code. it doesnt say what dev needs extra for the code i write...like the cin.get(); command..these things are not listed..sorry to waste time...peace