Brett McCoy wrote:
> On Nov 4, 2007 4:39 AM, 崔健 <[EMAIL PROTECTED]> wrote:
>> for C :
>>   I like use "break" to stop a loop.But ......like this:
>>
>>   
>> for(i=0;i<=5;i++)................................................................loop
>>  1
>>      {
>>       scanf( "%d" , a[i] );
>>       if( a[i] == ' ? ' )
>>         break;
>>      }
>>
>>   
>> for(i=0;i<=5;i++)................................................................loop
>>  2
>>       scanf( "%d" , b[i]);
>>
>>   when I enter '?' , it "break" , both the loop 1 and loop 2. But I only 
>> want to break loop 1 . The condition is that I can't scan the numbers to b[].
> 
> You should run this thorugh a debugger to step through the code to see
> what it's really doing. break shouldn't stop the second loop from
> running.
> 
> -- Brett
> ------------------------------------------------------------
> "In the rhythm of music a secret is hidden;
>     If I were to divulge it, it would overturn the world."
>                -- Jelaleddin Rumi

No, but scanf() might.  It probably never hits the break in the first
place when the bogus character ? is entered into the data stream.  Also,
the code pasted above shouldn't compile...there are spaces surrounding
the ?.  It should be '?', not ' ? '.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to