Created
July 12, 2018 08:13
-
-
Save settermjd/280b4bc4d387a3c6f126ed7d6a059ccb to your computer and use it in GitHub Desktop.
A small C program for the sakes of demonstrating cyclomatic complexity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whenever I use gnu complexity on it, it prints out "No procedures were scored". Anyone know why?