Do ICMP attack want to take IP as user input, suddenly found themselves even transfer structure parameters are not, this is first from small program test, figure out later can proceed.
First, passing struct variables:
#include <stdio.h>structpara{Char*A;intb;};voidPrintstructpara f) {printf ("a=%s\nb=%d\n", f.a,f.b);}voidMain () {structpara p; P.a="ABC"; P.B= A; Print (P);}
Second, passing struct-body pointers:
#include <stdio.h>structpara{Char*A;intb;};voidPrintstructPara *f) {printf ("a=%s\nb=%d\n",f->a,f->b);}voidMain () {structpara p; P.a="ABC"; P.B= A; Print (&p);}
If you define a struct pointer, you must first allocate space for it, otherwise the value assigned later is not stored. Assign with malloc and remember to add a header file.
However, the struct pointer refers to the struct member, the symbol is used.
#include <stdio.h>#include<stdlib.h>structpara{Char*A;intb;};voidPrintstructPara *f) {printf ("a=%s\nb=%d\n",f->a,f->b);}voidMain () {structPara *p; P=(structpara*) malloc (sizeof(structpara)); P->a="ABC"; P->b= A; Print (P);}
This seems to be a freshman study of the content, are graduating quickly unexpectedly forget, are embarrassed to say that they are computer professional ...
C language--structure function parameter