Click here to Skip to main content
15,918,243 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionUser Input Pin
Harold_Wishes7-Jul-06 5:26
Harold_Wishes7-Jul-06 5:26 
AnswerRe: User Input Pin
Zac Howland7-Jul-06 5:31
Zac Howland7-Jul-06 5:31 
GeneralRe: User Input Pin
Harold_Wishes7-Jul-06 5:51
Harold_Wishes7-Jul-06 5:51 
GeneralRe: User Input Pin
Zac Howland7-Jul-06 6:04
Zac Howland7-Jul-06 6:04 
GeneralRe: User Input Pin
Harold_Wishes7-Jul-06 7:06
Harold_Wishes7-Jul-06 7:06 
GeneralRe: User Input Pin
Zac Howland7-Jul-06 7:33
Zac Howland7-Jul-06 7:33 
GeneralRe: User Input Pin
Harold_Wishes7-Jul-06 10:08
Harold_Wishes7-Jul-06 10:08 
GeneralRe: User Input [modified] Pin
Zac Howland7-Jul-06 10:35
Zac Howland7-Jul-06 10:35 
Try this:

#include <string>
#include <list>
#include <iostream>

using namespace std;

struct data 			// renamed to more meaningful name (granted, not much more)
{
     string Length;
     string Sequence;
     string N_Terminal;
     string C_Terminal;
};				// removed pointer since list class would be better choice

//node *start_ptr = NULL;
//node *current;		 // no longer needed

list<data> g_DataList;		// global list of data

char selectionMenu()
{
	char selection = 0;	// your menu allows for only a single char
				// no need to allocate a string for that
	cout << "Please Select the sequence type: " << endl;
	cout << endl;
	cout << "A) Complete  B) Partial  C) UNKNOWN" << endl;
	cin >> selection;
	return selection;
}

bool isValidSelection(char selection)
{
	switch (selection)
	{
	case 'A':
	case 'a':
	case 'B':
	case 'b':
	case 'C':
	case 'c':
		return true;
	default:
		return false;
	}
}

string getSelectionString(char selection)
{
	string result = "UNKNOWN";	// C/c is the default
	switch (selection)
	{
	case 'A':
	case 'a':
		result = "Complete";
		break;
	case 'B':
	case 'b':
		result = "Partial";
		break;
	}

	return result;
}

void add_Part_one (string& data1, int& data2)
{
	char selection = 0;
	do
	{
		selection = selectionMenu();
	} while (!isValidSelection(selection));

	data1 = getSelectionString(selection);

	char buffer[100] = {0};
	cout << "Please enter the number of subunits: ";
	cin >> data2;
	cin.getline(buffer, 99, '\n');	// to get endline character out of the way
}

void add_node_at_end()
{        
	data temp;	// what we are adding to	 
	char buffer[501] = {0};	// buffer for input

	cout << "Please enter the length of the protein sequence: ";
	cin.getline(buffer, 500, '\n');
	temp.Length = buffer;
	memset(buffer, 0, 501);

	cout << "Please enter the protein sequence : ";
	cin.getline(buffer, 500, '\n');
	temp.Sequence = buffer;
	memset(buffer, 0, 501);

	cout << "Enter brief status on the presence of a modified N_Terminal: ";
	cin.getline(buffer, 500, '\n');
	temp.N_Terminal = buffer;
	memset(buffer, 0, 501);

	cout << "Enter brief status on the presence of a modified C_Terminal: ";
	cin.getline(buffer, 500, '\n');
	temp.C_Terminal = buffer;
	memset(buffer, 0, 501);

	g_DataList.push_back(temp);	// add to list

	cout << endl;
}

int main()
{
	int number_of_subunits = 1;
//	string SEQUENCE_TYPE;	// just an FYI:  
				// variable names that are all caps are typically thought to be const
				// it is bad form to create non-const variables with all caps names
   	string sequenceType;

	add_Part_one(sequenceType, number_of_subunits);
   	for (int counter = 0; counter < number_of_subunits; counter++)
	{  
		add_node_at_end();
	}

	return 0;
}


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

-- modified at 16:36 Friday 7th July, 2006
GeneralRe: User Input [modified] Pin
Harold_Wishes8-Jul-06 17:36
Harold_Wishes8-Jul-06 17:36 
GeneralRe: User Input Pin
Zac Howland9-Jul-06 14:28
Zac Howland9-Jul-06 14:28 
QuestionSimple MAPI Outlook outbox problem Pin
chilituna7-Jul-06 4:45
chilituna7-Jul-06 4:45 
Questionostream operator link error Pin
mosu'7-Jul-06 4:33
mosu'7-Jul-06 4:33 
AnswerRe: ostream operator link error [modified] Pin
Viorel.7-Jul-06 4:45
Viorel.7-Jul-06 4:45 
AnswerRe: ostream operator link error Pin
Zac Howland7-Jul-06 5:11
Zac Howland7-Jul-06 5:11 
QuestionRun an application inside another one Pin
xtof737-Jul-06 4:03
xtof737-Jul-06 4:03 
AnswerRe: Run an application inside another one Pin
Sarath C7-Jul-06 4:25
Sarath C7-Jul-06 4:25 
GeneralRe: Run an application inside another one Pin
Zac Howland7-Jul-06 4:30
Zac Howland7-Jul-06 4:30 
GeneralRe: Run an application inside another one Pin
Sarath C7-Jul-06 4:39
Sarath C7-Jul-06 4:39 
AnswerRe: Run an application inside another one Pin
Jun Du7-Jul-06 4:40
Jun Du7-Jul-06 4:40 
QuestionCListCtrl and Graphic Pin
ensger7-Jul-06 3:44
ensger7-Jul-06 3:44 
AnswerRe: CListCtrl and Graphic Pin
Zac Howland7-Jul-06 5:25
Zac Howland7-Jul-06 5:25 
GeneralRe: CListCtrl and Graphic Pin
ensger7-Jul-06 9:10
ensger7-Jul-06 9:10 
QuestionCreating a Bitmap from a Framegrabber Image Pin
im797-Jul-06 3:41
im797-Jul-06 3:41 
AnswerRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay7-Jul-06 6:27
Justin Tay7-Jul-06 6:27 
AnswerRe: Creating a Bitmap from a Framegrabber Image Pin
im799-Jul-06 4:37
im799-Jul-06 4:37 

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.