CS 153 Data Structures I
Programming Assignment #2
Due: 1/25/00
This programming assignment is designed to:
-
review the use of Edit Boxes
-
review the use of Buttons
-
review the use of CStrings
-
review/use char arrays
-
review/use char array functions
Create a VC++ GUI that contains the following edit boxes
-
Full SSN (type is CString)
-
1st 3 digits of SSN (type is int)
-
2nd 2 digits of SSN (type is int)
-
3rd 4 digits of SSN (type is int)
and the following buttons
-
Concatenate from Individual numbers to Full
-
Parse from Full SSN to Individual numbers
When Button Concatenate is clicked the contents of 1st, 2nd and
3rd should be formatted and placed into Full SSN as: 123-45-6789
When Button Parse is clicked the contents of Full SSN should be parsed
into 1st, 2nd and 3rd as: 123 45
6789
Upon entering an OnButtonParse function:
-
UpdateData(TRUE);
-
You must move the individual characters from the CString to 3 seperate
NULL terminated character arrays
-
Use the library function atoi(...) to convert the 3 character arrays to
3 ints.
-
UpdataData(FALSE);
Upon entering an OnButtonConcatenate function:
-
UpdateData(TRUE);
-
You must convert the 3 ints to 3 NULL terminated character arrays using
the library function itoa(...)
-
Assisn the 1st character array to a CString variable.
-
Concatenate a "-" followed by the 2nd character array followed by another
"-" etc.
-
UpdataData(FALSE);
void CProg2Dlg::OnBUTTONParse()
{
char first[4], second[3], third[5], all[10];
UpdateData(TRUE);
strcpy(all,m_Full);
strncpy(first,all+0,3);
m_1st = atoi(first);
strncpy(second,all+4,2);
m_2nd = atoi(. . .
.
UpdateData(FALSE);
}