Skip to content

Instantly share code, notes, and snippets.

@settermjd
Created July 12, 2018 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save settermjd/280b4bc4d387a3c6f126ed7d6a059ccb to your computer and use it in GitHub Desktop.
Save settermjd/280b4bc4d387a3c6f126ed7d6a059ccb to your computer and use it in GitHub Desktop.
A small C program for the sakes of demonstrating cyclomatic complexity
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t t = time(NULL);
struct tm tm = *localtime(&t);
const char * months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
if (tm.tm_year == 2018 &&
strncmp(months[tm.tm_mon], "November", strlen(months[tm.tm_mon])) == 0
&& tm.tm_mday == 10)
{
printf("Happy C Day!.\n");
} else {
printf("The current month is %s.\n", months[tm.tm_mon]);
}
}
@settermjd
Copy link
Author

Whenever I use gnu complexity on it, it prints out "No procedures were scored". Anyone know why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment