Hi, currently im working on a project for uni but i have no knowledge in C at all

basically what im trying to do is remove all * !"£$%^&*()- and double spaces from a text file
so far i am able to copy the text file so that im not using the original one so the user inputs what file they want to open and then specifies which name to save it as
has anyone any idea how this works
currently i have this

FILE * fpIn;
FILE * fpOut;
char a;  
char *a                        									
char array[100];
char filename[50];                      								
char filename1[50];                 								
int main(void)

{
printf("Enter the name of file to open ");	 
gets(filename);      								
fpIn=fopen(filename,"r");								    

if
(fpIn==NULL)
   printf("ERROR - cannot open file please try again");	
   else
   printf ("Enter the name you wish to call the new file ");
   gets(filename1);					
   	
  fpOut=fopen(filename1,"w");								
   if (fpOut==NULL)					
   printf("Error cannot write new file! please try again");	
   else
	printf("File has opened correctly");
   while(fgets(array, sizeof(array), fpIn))   
   {
      fprintf(fpOut, "%s", array); 			
   }
   fclose(fpIn);
   fclose(fpOut);											
   return 0;
}

this is a massive thing for me to do as i am basically self learning in 5 days please can anyone help me

i have tried

if ((a = strchr(array, '\n')) != NULL)
*a = '\0';

please can someone help

Look up the function isalpha() and test each character after you read the line.

Also, see this about gets().
And see this about formatting. Yours is not very good.

Look up the function isalpha() and test each character after you read the line.

Also, see this about gets().
And see this about formatting. Yours is not very good.

once I find the code I want to remove how do I remove it?

Don't output it.

One option would be to read in one character at the time, using e.g. fgetc(), filtering out the unwanted characters. To write to output file, you'd probably like to use the counterpart putc() .

This would narrow down the task at hand, which might be a good idea given your 5 days of programming experience.

basically what im trying to do is remove all * !"£$%^&*()- and double spaces from a text file

You could write your own iswhatever() type of function -- a linear search through "*!"£$%^&*()-" would find these. You might also look into ispunct(). The double-spaces would be a little extra.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.