当前位置:网站首页>A summary of the experiment of continue and break in C language
A summary of the experiment of continue and break in C language
2022-06-25 05:03:00 【MondayCat111】
Pass the test , There's something about c What I learned , Write it down here . Attach code snippet :
#include <stdio.h>
void main()
{
int i;
for(i=0;i<4;i++)
switch(i)
{
default:printf("%d",i+1);
case 1:printf("%d",i);
case 2:printf("%d",i);
}
}
The output is 100 11 2 433. When case There is no break All the following statements will be executed , If i stay case Are there in ,i The previous content will not be executed , Whether to execute the following contents to see if there is break sentence .
If switch Replace the sentence inside with
default:printf("%d",i+1);
case 1:printf("%d",i);break;
case 2:printf("%d",i);break;
The output is 10 1 2 43. If you will case 1 hinder break Replace with continue, The output is still 101243.
summary :continue Statement will terminate switch loop , bring for Inside i Become the next ( That is to end this cycle , Start the next cycle ). So in this case continue And break about switch It's the same thing , And as long as case perhaps default Not in use break It will be executed until the last sentence .
Attach the original words of the book ( Madman c The fifth chapter ):break Statements can also be used in loop statements , The function is to end break The innermost loop statement in which the statement is located ;continue Statement acts on a loop statement , The function is to turn into a circular statement () Continue to execute loop statements within .
边栏推荐
猜你喜欢

Activereportsjs V3.0 comes on stage

dotnet-exec 0.4.0 released

Matlab notes

Read the general components of antd source code

How to open the DWG file of the computer

Compatible with Internet Explorer

"Daily practice, happy water" 1108 IP address invalidation

Detailed summary of flex layout

How do the defi protocols perform under this round of stress test?

Use serialize in egg to read and write split tables
随机推荐
ORA-00800: soft external error
How to open the DWG file of the computer
Filter & listener (XIV)
The SQL response is slow. What are your troubleshooting ideas?
Laravel Aurora push
Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from
How PHP gets the user's City
OOP stack class template (template +ds)
Vscade setting clang format
Records of ros2/dds/qos/ topics
Leader: who can use redis expired monitoring to close orders and get out of here!
MySQL prevents Chinese garbled code and solves the problem of Chinese garbled code
Five simple data types of JS
My IC journey - the growth of senior chip design verification engineers - "Hu" said that IC engineers are perfect and advanced
Database overview
本轮压力测试下,DeFi协议们表现如何?
DMA double buffer mode of stm32
Detailed summary of float
Svg code snippet of loading animation
Introduction to the hardest core PWN in the whole network_ Graphic analysis