Hi I was hoping if anyone could help me figure out what im doing wrong. I wanted to delete a specific line in a text file using fputs...I dont know why it isn't writing on the textfile in other cases it only writes in the end of the file..'
heres the code...I really appreciate any help...
#include <stdio.h>
#include <string.h>
int main(void)
{
FILE * pFile;
char mystring [10000];
char w[10000];
char t[10];
int i,a=0,s=0;
printf("Enter word to search\n");
gets(t);
pFile = fopen ("dumpbeta.txt" , "r+");
if (pFile == NULL)
printf("Error opening file");
else
{
while(fgets (mystring,10000 ,pFile))
{
a++;
for(i = 0; mystring[i] != '\n' && mystring[i] != EOF;i++);
mystring[i] = '\0';
if(s==0)
{
strcpy(w,mystring);
strtok(mystring,"@");
}
if(strcmp(mystring,t)==0)
s=a;
}
}
if(s==0)
printf("No search found!");
else
{
char *result = NULL;
result = strtok( w,"@" );
while( result != 0) {
result = strtok( 0,"@" );
}
}
fclose(pFile);
return 0;
}