课程: Complete Guide to C Programming Foundations
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Avoiding the goto keyword
- [Instructor] The GOTO keyword alters program flow, but it does so in a manner that's difficult to follow. Therefore, using it isn't advised, nor is it even necessary. This exercise file shows the GOTO construction. The keyword at line 11 is followed by a label which indicates where execution jumps. The label is located at line seven at the start of the line. The label name is followed by a colon, not a semicolon. This is the label format in C with a label name using the same naming convention as for a variable. The GOTO jump works only within a function. So both the GOTO statement and its label appear here in the main function. Effectively, this code shows a loop counting down from 10 to one, and there's the output. Better ways are available to generate this same type of output without using a GOTO statement. Further, you can't use a break keyword to disrupt such a loop because a loop isn't truly implemented here, there's nothing to break. Here you see one way to break out of a GOTO…
内容
-
-
-
-
-
-
Making a decision3 分钟 25 秒
-
(已锁定)
Exploring the possibilities2 分钟 53 秒
-
(已锁定)
Using the ternary operator3 分钟
-
Working with the switch-case structure4 分钟
-
(已锁定)
Challenge: Select an item28 秒
-
(已锁定)
Solution: Select an item1 分钟 45 秒
-
Creating a for loop3 分钟 36 秒
-
(已锁定)
Setting up a while loop2 分钟 58 秒
-
(已锁定)
Challenge: Repeat some text51 秒
-
(已锁定)
Solution: Repeat some text1 分钟 51 秒
-
(已锁定)
Nesting loops1 分钟 59 秒
-
(已锁定)
Breaking out of a loop3 分钟 16 秒
-
(已锁定)
Avoiding the goto keyword1 分钟 33 秒
-
(已锁定)
Chapter challenge: Interpreting commands2 分钟 26 秒
-
(已锁定)
Chapter solution: Interpreting commands3 分钟 55 秒
-
-
-
-
-
-
-
-