Skip to content

Instantly share code, notes, and snippets.

@miwarin
Created October 15, 2017 05:59
Show Gist options
  • Save miwarin/c8fbac093bb2edb3a8de4caf7578f665 to your computer and use it in GitHub Desktop.
Save miwarin/c8fbac093bb2edb3a8de4caf7578f665 to your computer and use it in GitHub Desktop.
IPアドレス解析
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int ac, char** av)
{
char *s, *p, *tokens[8];
char *last;
int i = 0;
s = av[1];
for((p = strtok_r(s, ".", &last)); p; (p = strtok_r(NULL, ".", &last)), i++)
{
tokens[i] = p;
}
tokens[i] = NULL;
if(i != 4)
{
puts("False");
return 1;
}
puts("True");
// for(i = 0; tokens[i] != NULL; i++)
// {
// printf("%s\n", tokens[i]);
// }
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment