I have the following code and there are two sections commented out that i want to make into functions arg_val and print_data these functions will go into a separate file called func.c im not to sure about making these functions that will work in a external file

anyway heres the code ||||||
VVVV

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MAXLEN 81


struct used
{
int ln;
struct used *next;
};

struct identifier
{
char ID [11];
int definition;
int ismultdef;
struct identifier *next;
struct used *use;
};

int main (int argc, char* argv[])
{
struct identifier *head=NULL;
struct identifier *cur=NULL;
struct used *cur2=NULL;
char *idname;
char line [MAXLEN];
FILE *foutp, *finp;
int linenum=1;
int COUNT=0;


**************************************************
*************************************************
i want to take the following code and make it a function called arg_val
and this will be put into a separate file called func.c
************************************************** *

if (argc < 3)
{
printf("usage : p2 input output -m -n \n");
exit (1);
}
if (argc >5)
{
printf("usage : p2 input output -m -u \n");
exit (1);
}
if((strcmp(argv[1],argv[2])==0))
{
printf("test\n");
exit (1);
}



if(argc==4)
{
printf("ok\n");
if(strcmp(argv[3], "-m")==0)
printf("-m\n");
else if (strcmp(argv[3], "-u")==0)
printf("-u\n");
else
{
printf("error invalid flags usage -m -u\n");
exit(1);
}
}

if(argc==5)
{
printf("ok\n");

if(strcmp(argv[3], "-m")==0)
printf("-m\n");
else if (strcmp(argv[3], "-u")==0)
printf("-u\n");
else
{
printf("error invalid flags usage -m -u\n");
exit(1);
}
if(strcmp(argv[3],argv[4])==0)
printf("test1\n");
else
{
if(strcmp(argv[4],"-m")==0)
printf("-m\n");
else if (strcmp(argv[4], "-u")==0)
printf("-u\n");
else
{
printf("error\n");
exit(1);
}
}
}

if((finp=fopen(argv[1],"r"))==NULL)
{
printf("error\n");
exit(1);
}

if((foutp=fopen(argv[2],"w"))==NULL)
{
printf("error\n");
exit(1);
*/*************************************************
*************end of arg_val**************************
}


while(fgets(line, MAXLEN,finp)!=NULL)
{
int COUNT=0;
if(line[COUNT]=='#')
{
fprintf(foutp,"%d %s", linenum++,line);
continue;
}

if((line[COUNT]=='_') || isalpha(line[COUNT]))
{
fprintf(foutp,"%d %s", linenum++,line);
idname=strtok(line,":");
if(head==NULL)
{

head=(struct identifier *)malloc(sizeof(struct identifier));
head->definition=linenum-1;
head->ismultdef-1;
head->next=NULL;
head->use=NULL;
strcpy(head->ID, idname);
}

else
{
for(cur=head;cur!=NULL;cur=cur->next)
{
if(strcmp(cur->ID, idname)==0)
{
if(cur->ismultdef==0)
cur->definition=linenum-1;
cur->ismultdef++;
break;
}
if(cur->next==NULL)
{
cur->next=(struct identifier *)malloc(sizeof(struct identifier));
cur=cur->next;
cur->definition=linenum-1;
cur->ismultdef=1;
cur->next=NULL;
cur->use=NULL;
strcpy(cur->ID, idname);
break;
}
}
}
idname=strtok(NULL,"\t\n,");
while(idname!=NULL)
{
idname=strtok(NULL,"\t\n,");
if(idname==NULL)
break;
if(isdigit(idname[0])||idname[0]=='\"'||idname[0]=='\''||idname[0]=='#')
break;
if(isalpha(idname[0])||idname[0]=='_')
{
if(head==NULL)
{
head=(struct identifier *)malloc(sizeof(struct identifier));
head->ismultdef=0;
head->next=NULL;
strcpy(head->ID,idname);
head->use=(struct used *)malloc(sizeof(struct used));
cur2=head->use;
cur2->ln=linenum-1;
cur2->next=NULL;
}
else
{
for(cur=head;cur!=NULL;cur=cur->next)
{
if(strcmp(cur->ID,idname)==0)
{
if(NULL==cur->use)
{
cur->use=(struct used *)malloc(sizeof(struct used));
cur2=cur->use;
cur2->ln=linenum-1;
cur2->next=NULL;
}
else
{
for(cur2=cur->use;cur2!=NULL;cur2=cur2->next)
{
if(cur2->ln==linenum-1)
break;
if(cur2->next==NULL)
{
cur2->next=(struct used*)malloc(sizeof(struct used));
cur2=cur2->next;
cur2->ln=linenum-1;
cur2->next=NULL;
break;
}
}
}
break;
}
if(cur->next==NULL)
{
cur->next=(struct identifier *)malloc(sizeof(struct identifier));
cur=cur->next;
cur->ismultdef=0;
cur->definition=-1;
cur->next=NULL;
strcpy(cur->ID,idname);
cur->use=(struct used *)malloc(sizeof(struct used));
cur2=cur->use;
cur2->ln=linenum-1;
cur2->next=NULL;
break;
}
}
}
}
}
continue;
}
if((line[COUNT]==' ')|| (line[COUNT]=='\t'))
{
while((line[COUNT] ==' ')||(line[COUNT]=='\t'))
{
COUNT++;
}

if(line[COUNT]=='#')
{
fprintf(foutp,"%d %s",linenum++,line);
continue;
}

if((line[COUNT]=='.')||(isalpha(line[COUNT])))
{
fprintf(foutp,"%d %s",linenum++,line);
idname=strtok(line,"\t\n,");
while(idname!=NULL)
{
idname=strtok(NULL,"\t\n,");
if(idname==NULL)
break;
if(isdigit(idname[0])||idname[0]=='\"'||idname[0]=='\''||idname[0]=='#')
break;
if(isalpha(idname[0])||idname[0]=='_')
{
if(head==NULL)
{
head=(struct identifier *)malloc(sizeof(struct identifier));
head->ismultdef=0;
head->next=NULL;
strcpy(head->ID,idname);
head->use=(struct used *)malloc(sizeof(struct used));
cur2=head->use;
cur2->ln=linenum-1;
cur2->next=NULL;
}
else
{
for(cur=head;cur!=NULL;cur=cur->next)
{
if(strcmp(cur->ID,idname)==0)
{
if(NULL==cur->use)
{
cur->use=(struct used *)malloc(sizeof(struct used));
cur2=cur->use;
cur2->ln=linenum-1;
cur2->next=NULL;
}
else
{
for(cur2=cur->use;cur2!=NULL;cur2=cur2->next)
{
if(cur2->ln==linenum-1)
break;
if(cur2->next==NULL)
{
cur2->next=(struct used *)malloc(sizeof(struct used));
cur2=cur2->next;
cur2->ln=linenum-1;
cur2->next=NULL;
break;
}
}
}
break;
}
if(cur->next==NULL)
{
cur->next=(struct identifier *)malloc(sizeof(struct identifier));
cur=cur->next;
cur->ismultdef=0;
cur->definition=-1;
cur->next=NULL;
strcpy(cur->ID,idname);
cur->use=(struct used *)malloc(sizeof(struct used));
cur2=cur->use;
cur2->ln=linenum-1;
cur2->next=NULL;
break;
}
}
}
}
}
continue;
}
************************************************** *
****this also should go into func.c as a function print_dat..........*
************************************************** *
}
if(line[COUNT]=='\n')
fprintf(foutp,"\n");
}
fprintf(foutp,"\n\n\t cross reference table\n");
for(cur=head;cur!=NULL;cur=cur->next)
{
fprintf(foutp,"%s\t\t%d\t\t", cur->ID,cur->definition);
for(cur2=cur->use;cur2!=NULL;cur2=cur2->next)
fprintf(foutp,"%d ",cur2->ln);
fprintf(foutp,"\n");
}
fprintf(foutp,"\nmultiply defined \n");
for(cur=head;cur!=NULL;cur=cur->next)
{
if(cur->ismultdef>1)
fprintf(foutp,"%s\n",cur->ID);
}
fprintf(foutp,"\nundefined\n");
for(cur=head;cur!=NULL;cur=cur->next)
{
if(cur->definition==-1)
fprintf(foutp,"%s\n",cur->ID);
}
*/**************************************************
**********end of print_dat..........*************************
*************************************************
return 0;
}