LINUX C Programming Lists IP segment.

xiaoxiao2021-03-06  58

LINUX C Programming Lists IP segment.

One idea:

Some scanners may need to provide IP lists. This can be used as an input to the IP file by some scanners, and now you can write the program to provide these IPs.

Second function description.

Where the selection function Switch. Loop function for check the related function description. Not explained here!

Three writing procedures:

Creating a file: Nightcat @ nightcat $ vi showip.c

Edit the following:

/*SHOWIP.C Version 1.0

* The Tools Show IP Include A B And C Class's IP

* You can see the tips for entering.

* The Tools Writen By Nightcat Email: ncnynl@hotmail.com

* * Code by Nightcat

* April 2003

* * /

#include

Main ()

{

Int Chioce, I, J, K, A, B, C;

File * fp;

Printf ("Please Enter Your Chioce, / N Enter 1 Chioce a Class./n Enter 2 Chiose B Class. / N Enter 3 Chiose C Class: / N");

Scanf ("% D", & chioc);

Switch (chioc) {

Case 1: Printf ("Enter A as 211 ENTER / '-1 /' TO End / N"); Scanf ("% D", & A); IF (A == - 1) {

Break;

} IF ((FP = FOPEN ("Listipa.txt", "W ")) == null) {Printf ("cann't open files./n"); exit (1);} for (i = 1; i <= 254; i ) {for (j = 1; j <= 255; j ) {for (k = 1; k <= 255; k ) fprintf (fp, "% d.% d.% d.% D / N ", A, I, J, K);}} fclose (fp); Break; Case 2: Printf (" Enter B AS 211.239 ENTER / '- 1 /' TO End / N "); scanf (" % D.% D ", & A, & B); if (a == - 1) {Break;} IF ((fp = fopen (" Listipb.txt "," W ")) == null) {Printf (" Cann't open files / n "); exit (1);} for (i = 1; i <= 255; i ) {for (j = 1; j <= 255; j ) {fprintf (fp, "% d.% d.% D% .d / n", a, b, i, j);}} fclose (fp); Break;

Case 3: Printf ("Enter C AS 211.239.151 ENTER / '- 1 /' TO End / N"); Scanf ("% D.% d.% d", & a, & b, & c); if (a = = -1) {Break;} IF ((fp = fopen ("Listipc.txt", "W "))) == null) {Printf ("cann't open files / n"); exit (1);} For (i = 1; i <= 255; i ) {fprintf (fp, "% d.% d.% d.% d / n", a, b, c, i);} fclose (fp); Break }}

Save exit:

: WQ

Compilation execution: Nightcat @ nightcat $ gcc -o showip showip.cnightcat@nightcat $./show

I'm later:

This program is very simple. Mainly in the selection function Switch, and loop functions for.

There is also the read and write function of the file. FOPEN, FPRINTF.FCLOSE.

Five. Contact me:

Nickname: Nightcat

E-mail: ncnynl@hotmail.com

QQ: 1043931

ICQ: 153436005

转载请注明原文地址:https://www.9cbs.com/read-119313.html

New Post(0)