Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Splint (programming tool)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example== <syntaxhighlight lang="c"> #include <stdio.h> int main() { char c; while (c != 'x'); { c = getchar(); if (c = 'x') return 0; switch (c) { case '\n': case '\r': printf("Newline\n"); default: printf("%c",c); } } return 0; } </syntaxhighlight> Splint's output: <pre><nowiki> Variable c used before definition Suspected infinite loop. No value used in loop test (c) is modified by test or loop body. Assignment of int to char: c = getchar() Test expression for if is assignment expression: c = 'x' Test expression for if not boolean, type char: c = 'x' Fall through case (no preceding break) </nowiki></pre> Fixed source: <syntaxhighlight lang="c"> #include <stdio.h> int main() { int c = 0; // Added an initial assignment definition. while (c != 'x') { c = getchar(); // Corrected type of c to int if (c == 'x') // Fixed the assignment error to make it a comparison operator. return 0; switch (c) { case '\n': case '\r': printf("Newline\n"); break; // Added break statement to prevent fall-through. default: printf("%c",c); break; //Added break statement to default catch, out of good practice. } } return 0; } </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)