ips.c

来自「一个用在mips体系结构中的操作系统」· C语言 代码 · 共 36 行

C
36
字号
/* * Copyright (C) 1996-1998 by the Board of Trustees *    of Leland Stanford Junior University. *  * This file is part of the SimOS distribution.  * See LICENSE file for terms of the license.  * *//* * Generate list of SimOS IP addresses, given list of people and * number of addresses/person. * * ips <people-file> <n-per-person> <base-IP> * */#include <stdio.h>int main(int argc, char *argv[]){  FILE *people = fopen(argv[1], "r");  int  n       = atoi(argv[2]);  char *base   = argv[3];  char name[100];  int  i, k, a1, a2, a3, a4;  sscanf(base, "%d.%d.%d.%d", &a1, &a2, &a3, &a4);  for (k = 0; ; k += n) {    if (fscanf(people, "%s", name) != 1) return 0;    for (i = 0; i < n; i++)      printf("%d.%d.%d.%d\t%s-%d\n", a1, a2, a3, a4+k+i, name, i);    printf("\n");  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?