Here's the entirety, gcc -Wall doesn't complain, I don't think its the program's fault anyway...
Code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
int main(int argc, char *argv[])
{
//char name[1000];
FILE * report;
FILE * reformed;
FILE * buff;
char found[1000];
int a=0,i=0,b=0;
//puts("What file?");
//gets(name);
if((report = fopen(argv[1], "r+"))==NULL) {
printf("Cannot open file.\n");
Sleep(500);
exit(1);
}
reformed = fopen("reformated.txt","w+");
buff = fopen("buffer.txt","w+");
fseek ( report,0,SEEK_SET);
while(1 == fscanf(report,"%s",found))
{
if (strncmp(found,"<Billing_Type>",14)==0)
{
for(b=14;b<strlen(found)&&b<20;b++)
fprintf(buff,"%c",(char)found[b]);
}
if (strncmp(found,"<Patient_ID>",12)==0)
{
if(a>0)
{fprintf(buff,"\n");}
for(b=12;b<18;b++)
{fprintf(buff,"%c",(char)found[b]);}
a++;
}
if (strncmp(found,"<Patient_Name>",14)==0)
{
fprintf(buff,"_");
for(b=14;b<strlen(found);b++)
{
fprintf(buff,"%c",(char)found[b]);
}
}
if (strncmp(found,"<Patient_Index_Name>",20)==0)
{
fprintf(buff,"_");
for(b=20;b<strlen(found);b++)
{
fprintf(buff,"%c",(char)found[b]);;
}
}
}
fseek ( buff,0,SEEK_SET);
fseek ( reformed,0,SEEK_SET);
while(1 == fscanf(buff,"%s",found))
{
a=strlen(found)-1;
if ((found[a]=='r')||(found[a]==')'))
{
fprintf(reformed,found);
fprintf(reformed,"\n");
}
}
fclose(buff);
fclose(reformed);
fclose(report);
remove ("buffer.txt");
printf("Execution Successful!");
Sleep(1000);
return(0);
}