deleting numbers in text files

This is a discussion on deleting numbers in text files within the C Programming forums, part of the General Programming Boards category; HI people, I am trying to delete numbers from any text file. I have this much so far: Code: int ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    2

    deleting numbers in text files

    HI people,

    I am trying to delete numbers from any text file. I have this much so far:
    Code:
    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);
    	 }	 
    	 else{
    
    		   printf("could not open file ", filename);
    	 }
    	 if (isxdigit(fputc(c, stdout))){
    printf("\nThere is a number");
    	 }
    	 else
    	 {
    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
    thanks

    rick

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    Note that c should be of type int to correctly check the EOF condition
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 02: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, 05:43 AM
  5. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 10:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21