Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Passing a variable [modified] Pin
Harold_Wishes24-Jul-06 7:24
Harold_Wishes24-Jul-06 7:24 
GeneralRe: Passing a variable Pin
DanYELL24-Jul-06 7:40
DanYELL24-Jul-06 7:40 
GeneralRe: Passing a variable Pin
DanYELL24-Jul-06 7:44
DanYELL24-Jul-06 7:44 
QuestionRe: Passing a variable Pin
David Crow24-Jul-06 8:05
David Crow24-Jul-06 8:05 
AnswerRe: Passing a variable Pin
prasad_som24-Jul-06 19:00
prasad_som24-Jul-06 19:00 
Questioncin issues [modified] Pin
Harold_Wishes24-Jul-06 6:52
Harold_Wishes24-Jul-06 6:52 
AnswerRe: cin issues Pin
David Crow24-Jul-06 6:54
David Crow24-Jul-06 6:54 
GeneralRe: cin issues [modified] Pin
Harold_Wishes24-Jul-06 7:07
Harold_Wishes24-Jul-06 7:07 
Here is a condensed version. There are 2 functions below. Function 1 gets called before function 2. The problem appears in function 2 where I had to enter 2 cin statements. I hope it's readable as the cut and paste did not translate well.

void add_number_of_subunits (int& data)
{
    char buff[1024]; // stores whatever the user types in
    unsigned int value;
    int charsRead;

	
    bool validEntry = false; // sets a flag so that the
                            // validation can be performed
                             //in the loop below
	while (!validEntry)	
	{ 	
	  cout << endl;
	  cout << "Please enter number of subunits: ";
	  cin >> buff; 
		
	  if (sscanf(buff,"%u%n", &value,&charsRead)==1 && value >=1 && value <= 12)	
		validEntry = true;	// test to see if the user enter a valid integer
		                        // If it is valid, the flag is changed which allow the 
		                        // program  to exit the loop. If not, the flag remains
		                        // as is until the user enter a valid number.
	}

	data = value; // The value entered by the user is copied into "data" and returned to main()
	              // which determines the number of cycles the user will have to enter per
	              // subunit

}

void add_node_at_end(data& item, int& increment)
{    
	     // what we are adding to
	char buffer[501] = {0}; // buffer for input

	cout << "Please enter the length of the protein sequence for Subunit " << increment << "> ";

        cin >> buffer; // I had to enter 2 cin statements since  the compiler for whatever reason
	cin.getline(buffer, 500, '\n');               // was not accepting one of them.

	item.Length = buffer;
        memset(buffer, 0, 501);

	cout << "Please enter the protein sequence for Subunit " << increment << "> ";
	cin.getline(buffer, 500, '\n');

	while (buffer == "\n")
    {
		cout << "A sequence is required!" << endl;
		cout << "Please enter a sequence." << endl;
                cin.getline(buffer, 500, '\n');
    }

    item.Sequence = buffer;
    memset(buffer, 0, 501);
    item.number = item.Sequence.size();


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

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

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

    cout << endl;
	
	increment++;
}



-- modified at 13:08 Monday 24th July, 2006
QuestionRe: cin issues Pin
David Crow24-Jul-06 7:52
David Crow24-Jul-06 7:52 
AnswerRe: cin issues Pin
Harold_Wishes24-Jul-06 8:08
Harold_Wishes24-Jul-06 8:08 
GeneralRe: cin issues Pin
David Crow24-Jul-06 8:32
David Crow24-Jul-06 8:32 
GeneralRe: cin issues Pin
Zac Howland24-Jul-06 9:13
Zac Howland24-Jul-06 9:13 
GeneralRe: cin issues Pin
David Crow24-Jul-06 9:22
David Crow24-Jul-06 9:22 
GeneralRe: cin issues Pin
Zac Howland24-Jul-06 9:30
Zac Howland24-Jul-06 9:30 
GeneralRe: cin issues [modified] Pin
Harold_Wishes24-Jul-06 9:28
Harold_Wishes24-Jul-06 9:28 
GeneralRe: cin issues Pin
Harold_Wishes24-Jul-06 9:23
Harold_Wishes24-Jul-06 9:23 
GeneralRe: cin issues Pin
Zac Howland24-Jul-06 9:34
Zac Howland24-Jul-06 9:34 
GeneralRe: cin issues [modified] Pin
Harold_Wishes24-Jul-06 10:07
Harold_Wishes24-Jul-06 10:07 
GeneralRe: cin issues Pin
Zac Howland24-Jul-06 11:08
Zac Howland24-Jul-06 11:08 
GeneralRe: cin issues [modified] Pin
Harold_Wishes24-Jul-06 10:48
Harold_Wishes24-Jul-06 10:48 
GeneralRe: cin issues Pin
Zac Howland25-Jul-06 4:42
Zac Howland25-Jul-06 4:42 
QuestionRe: cin issues Pin
David Crow24-Jul-06 9:41
David Crow24-Jul-06 9:41 
QuestionDisplaying Multiple form in vc++ Pin
ningthemcha24-Jul-06 6:01
ningthemcha24-Jul-06 6:01 
AnswerRe: Displaying Multiple form in vc++ Pin
David Crow24-Jul-06 6:05
David Crow24-Jul-06 6:05 
QuestionVC++ 6.0 IDE mse.exe Pin
bob1697224-Jul-06 5:58
bob1697224-Jul-06 5:58 

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.