Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Hirsch
crap
Commits
0babe5a5
Commit
0babe5a5
authored
Aug 30, 2019
by
Alexander Hirsch
Browse files
Add goto
parent
ea5c2b6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
slides/c_slides.md
slides/c_slides.md
+37
-0
No files found.
slides/c_slides.md
View file @
0babe5a5
...
...
@@ -346,6 +346,43 @@ struct expression *expression_binary_op(enumbinary_op op,
-
No substitution for regular error checking!
-
Assertions are meant to catch programmer errors
## Goto
```
c
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
for
(
int
j
=
0
;
j
<
20
;
++
j
)
{
if
(
j
==
10
)
{
goto
loopexit
;
}
printf
(
"(%d,%d) "
,
i
,
j
);
}
printf
(
"
\n\n
"
);
}
loopexit
:
```
---
```
c
char
*
buffer
=
malloc
(
256
);
for
(
int
i
=
0
;
i
<
numberOfThings
;
i
++
)
{
if
(
giveMeThing
(
i
,
buffer
)
!=
OK
)
goto
error
;
if
(
processThing
(
buffer
)
!=
OK
)
goto
error
;
if
(
dispatchThing
(
i
,
buffer
)
!=
OK
)
goto
error
;
}
free
(
buffer
);
return
OK
;
error
:
free
(
buffer
);
return
OOPS
;
```
## Multiple Source Files
-
Header-files define types and declare functions
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment