Thread: deleting numbers in text files

  1. #1
    Registered User
    Join Date
    Apr 2010

    deleting numbers in text files

    HI people,

    I am trying to delete numbers from any text file. I have this much so far:
    int main(){
         char c, filename[10]; FILE *fp;
    	 printf("Eneter a filename");
    	 scanf("%s", filename);
    	 if((fp=fopen(filename, "r")) !=NULL){
    	      while ((c=fgetc(fp)) !=EOF)
    			fputc(c, stdout);
    		   printf("could not open file ", filename);
    	 if (isxdigit(fputc(c, stdout))){
    printf("\nThere is a number");
    printf("\nThere are no numbers");
     printf(" \nEnter a filename");
    	 scanf("%s", filename);
    The files opens, and compiles but it does not match numbers.
    Can anyone help


  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    If you want to check whether c is a numeric character, you probably need to do that before you destroy it (by reading the next character).

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    Note that c should be of type int to correctly check the EOF condition
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:01 PM
  2. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  3. text files in c++
    By DungeonMaster in forum C++ Programming
    Replies: 5
    Last Post: 03-14-2006, 03:48 PM
  4. How to copy a word or numbers from text to other location
    By trancedeejay in forum C Programming
    Replies: 12
    Last Post: 02-09-2006, 06:43 AM
  5. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM