Hi,
Im new to c programming.
I have one pdb file. i want to extract a string starting with ATOM and store it in a text file.
here is my program,
Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<fcntl.h>
#define size 50
main()
{
char temp[300],*ptr;
char sname[50],ws[50],buf[50],buf1[50],field[32];
FILE *file,*file1;
int n;
printf("Enter the Filename\n");
scanf("%s",sname);
file=fopen(sname,"r");
printf("Enter the Word to Search\n");
scanf("%s",ws);
file1=fopen("grep.txt","w");
while(fgets(temp,200,file)!=NULL)
{
ptr=strstr(temp,ws);
if(ptr!=NULL)
fprintf(file1,"%s",ptr);
}
fclose(file);
strstr function extract the intermediate ATOM and ATOMS too. but i want a string staring with ATOM.
Thanks in advance..