c++ help turning a while loop with a strcmp to a for loop ??

[b][red]This message was edited by cmps_getch at 2004-4-30 8:59:51[/red][/b][hr]
i WANT TO TURN THAT RED WHILE IN TO A FOR LOOP U KNOW LIKE

[CODE]for(int n=0; n<5; n++)[/CODE]

but i dont understand the strcmp(), "quit" how would i change it so its a for loop and im intering the info in the loop

[CODE]
[red]while(printf("Enter Social Security Number: "), strcmp(gets(ss), "quit"))[/red]
{
//Obtain a "random" list index
hashval = hash(ss);
//Attempt to add record to list
person = insert(ss, student_body, hashval);
if (person) //Indicate failure to add
printf("You have attempted to enter a duplicte record!
");
} /*end of while*/
[/CODE]


Comments

  • : i WANT TO TURN THAT RED WHILE IN TO A FOR LOOP U KNOW LIKE
    :
    : [CODE]for(int n=0; n<5; n++)[/CODE]
    :
    : but i dont understand the strcmp(), "quit" how would i change it so its a for loop and im intering the info in the loop
    :
    : [CODE]
    : while(printf("Enter Social Security Number: "), strcmp(gets(ss), "quit"))
    : {
    : //Obtain a "random" list index
    : hashval = hash(ss);
    : //Attempt to add record to list
    : person = insert(ss, student_body, hashval);
    : if (person) //Indicate failure to add
    : printf("You have attempted to enter a duplicte record!
    ");
    : } /*end of while*/
    : [/CODE]
    :

    For any expression x,
    while(x) == for(;x;)

    -potw
  • [b][red]This message was edited by cmps_getch at 2004-4-30 8:59:0[/red][/b][hr]
    i dont think you read my question i know how to do that. i need to know how to manipulate stcmp in to the for loop


  • : [b][red]This message was edited by cmps_getch at 2004-4-30 8:59:0[/red][/b][hr]
    : i dont think you read my question i know how to do that. i need to know how to manipulate stcmp in to the for loop
    :
    :
    :
    the correct answer is
    [code]
    for(int n=0; n<5; n++)
    { cout<<"Enter Social Security Number: ";
    strcmp(gets(ss), "quit");
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories