Skip to content

Instantly share code, notes, and snippets.

@rossdakin
Created June 30, 2015 07:16
Show Gist options
  • Save rossdakin/bff82c4d64ddc24227d2 to your computer and use it in GitHub Desktop.
Save rossdakin/bff82c4d64ddc24227d2 to your computer and use it in GitHub Desktop.
A simple program that let my college girlfriend "turn off the internet" on her roommate's computer.
# include <stdio.h>
# include <string.h>
void action (void);
int validate (void);
int main (void){
system ("cls");
printf ("\n\n\n ");
top1:
switch (validate()){
case -1:
system ("cls");
return (0);
break;
case 1:
action();
break;
default:
system ("cls");
printf ("\n WRONG!\n\n ");
goto top1;
}
return (0);
}
void action (void){
char d;
system("cls");
printf ("\n What is the will of God?");
top:
d = 0;
printf ("\n");
printf ("\n (1) Turn internet ON");
printf ("\n (2) Turn internet OFF");
printf ("\n (3) Quit");
printf ("\n");
printf ("\n > ");
scanf ("%d", &d);
switch (d){
case 1:
system ("ipconfig /renew");
system ("cls");
printf ("\n Internet ON!\n\n ");
system ("pause");
system ("cls");
break;
case 2:
system ("ipconfig /release");
system ("cls");
printf ("\n Internet OFF!\n\n ");
system ("pause");
system ("cls");
break;
case 3:
system ("cls");
break;
default:
system ("cls");
printf ("\n ERROR: %d not a choice!\a ", d);
goto top;
break;
}
}
/* Return 1 for good, 0 for bad, -1 for give up. */
int validate (void){
int i = 0;
char entry[20];
printf ("Enter password or \"quit\": ");
while ((entry[i] = (char)getchar()) != '\n'){
i++;
}
entry[i] = '\0';
if (!strcmp ("penguin", entry))
return (1);
else if (!strcmp ("quit", entry))
return (-1);
else
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment