C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C solved programs » C string programs

C program to remove alphabets from an alphanumeric string

In this C program, we are going to learn how to remove alphabets from a given alphanumeric string? If string contains alphabets and numbers both, this program will remove only alphabets from the string.
Submitted by IncludeHelp, on April 05, 2018

Given a string and we have to remove it all alphabets using C program.

If string contains alphabets and numbers both (or anything with the alphabets), program to check the alphabets, if found then program will remove them from the string.


    String is: "hello123"
    Final string is: "123"

    String is: "Call 100"
    Final string is: "100"

Program to remove all alphabets from given alphanumeric string in C

/* C program to remove all the characters 
* from the alphanumeric string

#include <stdio.h>
#include <string.h>

// This function removes all the chars
// used in the string passed and will leave
// only the alphanumeric characters
int RemoveChars(char *string)
	int length=0,i=0,j=0,k=0;

	length = strlen(string);

			if((string[j]>='a' && string[j]<='z') || (string[j]>='A' && string[j]<='Z'))
					string[k] = string[k+1];

// main function 
int main()
	char string[50]={0};

	printf("\nEnter the string : ");

	// pass the string to the function
	printf("Final string is : %s",string);
	return 0;


Run 1:
Enter the string : hello123 
Final string is : 123

Run 2:
Enter the string : Call 100 
Final string is : 100

You may also be interested in...

C/C++ Tips and Tricks...

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions