Click here to Skip to main content
16,019,618 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Hide window Pin
eusto22-Aug-06 9:44
eusto22-Aug-06 9:44 
QuestionError: Run-Time Check Failure #2 - Stack around the variable 'password' was corrupted. Pin
jon-8022-Aug-06 7:59
professionaljon-8022-Aug-06 7:59 
AnswerRe: Error: Run-Time Check Failure #2 - Stack around the variable 'password' was corrupted. Pin
Cedric Moonen22-Aug-06 8:23
Cedric Moonen22-Aug-06 8:23 
GeneralRe: Error: Run-Time Check Failure #2 - Stack around the variable 'password' was corrupted. Pin
jon-8022-Aug-06 8:42
professionaljon-8022-Aug-06 8:42 
GeneralRe: Error: Run-Time Check Failure #2 - Stack around the variable 'password' was corrupted. Pin
Cedric Moonen22-Aug-06 8:48
Cedric Moonen22-Aug-06 8:48 
GeneralRe: Error: Run-Time Check Failure #2 - Stack around the variable 'password' was corrupted. Pin
jon-8022-Aug-06 8:58
professionaljon-8022-Aug-06 8:58 
GeneralRe: Error: Run-Time Check Failure #2 - Stack around the variable 'password' was corrupted. Pin
Zac Howland22-Aug-06 9:25
Zac Howland22-Aug-06 9:25 
AnswerRe: Error: Run-Time Check Failure #2 - Stack around the variable 'password' was corrupted. Pin
Zac Howland22-Aug-06 9:38
Zac Howland22-Aug-06 9:38 
Just a recommendation:

#include <iostream>
#include <string>
#include <exception>

using namespace std;

string passwordEntry(int allowedSize)
{
	const int SIZE = 100;
	if (allowedSize > SIZE)
	{
		cout << "Password size is too large. Size limit is " << SIZE << endl;
		allowedSize = SIZE;
	}

	string password = "";
	char buffer[SIZE] = {0};
	cout << "Enter your password:";
	cin.getline(buffer, size);
	password = buffer;
    
	if (password.length() > allowedSize)
	{
		throw exception("Invalid password size!");
	}

	return password;
}
void main ()
{
	const int LEGAL_PASSWD_SIZE = 8;
	string password = "";

	try
	{
		password = passwordEntry(LEGAL_PASSWD_SIZE);
	}
	catch (const exception& e)
	{
		cout << e.what() << endl;
		password = "*********";
	}

	cout << "Password is stored as " << password.c_str() << endl;
}


If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

QuestionRadio Power Button Pin
siddhen22-Aug-06 7:31
siddhen22-Aug-06 7:31 
AnswerRe: Radio Power Button Pin
toxcct22-Aug-06 8:39
toxcct22-Aug-06 8:39 
Questionhow to create a table in the database using mfc Pin
vc++_fragrance22-Aug-06 4:46
vc++_fragrance22-Aug-06 4:46 
AnswerRe: how to create a table in the database using mfc Pin
Sarath C22-Aug-06 5:09
Sarath C22-Aug-06 5:09 
AnswerRe: how to create a table in the database using mfc Pin
Sarath C22-Aug-06 5:18
Sarath C22-Aug-06 5:18 
AnswerRe: how to create a table in the database using mfc Pin
David Crow22-Aug-06 6:07
David Crow22-Aug-06 6:07 
AnswerRe: how to create a table in the database using mfc Pin
vc++_fragrance22-Aug-06 22:35
vc++_fragrance22-Aug-06 22:35 
QuestionCode of RoundedRect() Function? Pin
prabhashmandal22-Aug-06 4:23
prabhashmandal22-Aug-06 4:23 
AnswerRe: Code of RoundedRect() Function? Pin
Sarath C22-Aug-06 4:58
Sarath C22-Aug-06 4:58 
QuestionBest way to control a LCD display using C++? Pin
xkrja22-Aug-06 3:50
xkrja22-Aug-06 3:50 
AnswerRe: Best way to control a LCD display using C++? Pin
Rage22-Aug-06 4:23
professionalRage22-Aug-06 4:23 
GeneralRe: Best way to control a LCD display using C++? Pin
xkrja22-Aug-06 8:13
xkrja22-Aug-06 8:13 
GeneralRe: Best way to control a LCD display using C++? Pin
Richard Andrew x6422-Aug-06 12:34
professionalRichard Andrew x6422-Aug-06 12:34 
GeneralRe: Best way to control a LCD display using C++? Pin
Jörgen Sigvardsson22-Aug-06 15:04
Jörgen Sigvardsson22-Aug-06 15:04 
GeneralRe: Best way to control a LCD display using C++? Pin
xkrja22-Aug-06 21:21
xkrja22-Aug-06 21:21 
QuestionSetting printing page height at runtime Pin
FraDes9922-Aug-06 3:49
FraDes9922-Aug-06 3:49 
QuestionProperties window control Pin
david_alcalde22-Aug-06 3:39
david_alcalde22-Aug-06 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.