×

C String Manipulation programs without using Library Functions

C string manipulation programs without using Library Functions

The string is the character list, and typically we operate with library functions to read and print the entire string, but here you can find a compilation of solved c example based on string manipulation. We can perform with strings and render most programs without using string.h in the header file.

We are going to get and manipulate will character from the character list, and use our specific technic to display the string.

List of solved string manipulation programs

C program to individually print all of the VOWEL and CONSONANT characters.

During this program, we will individually print all VOWEL and CONSONANT characters from an obtained string, the logic behind whilst implementing the entire program too effectively, you just have to check if those characters are vowels to print them out like vowels and not to print them as consonants.

#include<stdio.h>
int main()
{
    character text[100];
    int j;
    printf("Please enter any string character: ");
    gets(text);
    printf("Your String character is: ");
    for(j=0;text[j]!='\0';j++)
    {
        printf("%c",text[j]);
    }
    printf("\n");
    printf("VOWEL Characters is: ");
    for(j=0;text[j]!='\0';j++)
    {
        if(text[j]=='A' || text[j]=='a' || text[j]=='E' || text[j]=='e' || text[j]=='I' || text[j]=='j' || text[j]=='O' || text[j]=='o' || text[j]=='U' || text[j]=='u')
            printf("%c",text[j]);
    }
    printf("\n");
    printf("CONSONANT Characters is: ");
    for(j=0;text[j]!='\0';j++)
    {
        if(!(text[j]=='A' || text[j]=='a' || text[j]=='E' || text[j]=='e' || text[j]=='I' || text[j]=='j' || text[j]=='O' || text[j]=='o' || text[j]=='U' || text[j]=='u'))
            printf("%c",text[j]);
    }
    printf("\n");
    return 0;
}

Output:

C string manipulation programs without using Library Functions

C program to use a loop to print string one by one character.

As we notice, a string may be displayed through printf("percent s, "string variable), but in this approach, we will print string one by one character using a loop. Here the loop runs from 0 to Null.

#include<stdio.h>
int main()
{
    character text[100];
    int j;
    printf("Please enter any string character: ");
    gets(text);
    printf("Your String character is: ");
    for(j=0;text[j]!='\0';j++)
    {
        printf("%c",text[j]);
    }
    printf("\n");
    return 0;
}

Output:

C string manipulation programs without using Library Functions

C program to count a string of upper case, lower case, and special characters.

We'll be counting upper case, lower case, and special characters in this program. The logic behind implementing this system is too simple, if it is alphabet search for lower and upper case characters, if characters are not alphabets count them as special characters, just test characters is alphabet or no.

/*C program to count upper case, lower case and special characters in a string.*/
#include<stdio.h>
int main()
{
    char text[100];
    int j;
    int countLow,countUpp,countSpe;
    printf("Enter any string: ");
    gets(text);
    //here, we are printing string using printf
    //without using loop
    printf("Entered string is: %s\n",text);
    //count lower case, upper case and special characters
    //assign 0 to counter variables
    countLow=countUpp=countSpe=0;
    for(j=0;text[j]!='\0';j++)
    {
        //check for alphabet
        if((text[j]>='A' && text[j]<='Z') || (text[j]>='a' && text[j]<='z'))
        {
            if((text[j]>='A' && text[j]<='Z'))
            {
                //it is upper case alphabet
                countUpp++;
            }
            else
            {
                //it is lower case character
                countLow++;
            }
        }
        else
        {
            //character is not an alphabet
            countSpe++; //it is special character
        }
    }
    //print values
    printf("Upper case characters: %d\n",countUpp);
    printf("Lower case characters: %d\n",countLow);
    printf("Special characters: %d\n",countSpe);
    return 0;
}

Output:

C string manipulation programs without using Library Functions

C program to toggle the case of all string characters.

Therefore in the program, we will toggle the case of string for all characters. The logic behind such a program is to convert the character of the lowercase letter in the uppercase letters and the upper case character in the lowercase letters, but the first test whether the letter is an alphabet or not, if this is alphabet then just do it.

#include<stdio.h>
int main()
{
    character text[100];
    int k;
    printf("Please enter any string character: ");
    gets(text);
    printf("Your String character is: %s\n",text);
    for(k=0;text[k]!='\0';k++)
    {
        //check character is alphabet or not
        if((text[k]>='A' && text[k]<='Z')||(text[k]>='a' && text[k]<='z'))
        {
            //check for upper case character
            if(text[k]>='A' && text[k]<='Z')
                text[k]=text[k]+0x20;
            else
                text[k]=text[k]-0x20;
        }
    }
    printf("String after toggle case: %s\n",text);
    return 0;
}

Output:

C string manipulation programs without using Library Functions

Related Topics

Bar3d() function in C Graphics

The bar3d function is used to create a 2-dimensional filled-in rectangular bar. We can also create three-dimensional shapes in C using helpful function. The first step in creating this 3D...

3 minutes read.

Palindrome Number in C

What is a Palindrome? A number that doesn't change when reversed is known as a palindrome. We reverse a number and compare it to the original number to determine whether it is...

4 minutes read.

Star Program in C Language

Star Program in C Star patterns are a sequence of * or any other character used to construct any pattern or any like-square geometric form, triangle, hollow square, pyramid, rhombus, etc.  Many programmers worldwide highly...

4 minutes read.

Find a subarray with a given sum.

Find a subarray with a given sum. The simple solution is to recognize all subarrays one by one and to check each subarray's sum. The quick solution follows the following program. Algorithm: From...

4 minutes read.

Floor() Function in C

Floor() function is a built-in function in C which is defined in the math.h header file. This function is used to return the nearest integer value which is less than...

4 minutes read.

Break, continue and goto statement in C

Break statement Break statement is used to break the process of a loop (while, do while and for) and switch case. Syntax: break; Example 1 while(test Expression) { // codes if(condition for break){ break; } // codes } Example 2 For(int it, condition,...

1 minute read.

Dynamic memory allocation

Dynamic memory allocation is used to allocate the memory at runtime. It has following function within <stdlib.h> header file. Function Syntax malloc() malloc (number *sizeof(int)); calloc() calloc (number, sizeof(int)); realloc() realloc (pointer_name, number * sizeof(int)); free() free (pointer_name); malloc() function The process...

2 minutes read.

Prototype in C

A prototype is nothing but a model, a model of initial creation of an intended product. Similarly, in the C programming language, all functions have a prototype. In general, all...

4 minutes read.

Hook() function in C

Use of hook () function in C Introduction:  The hook () is a function used in the C programming language. The basic concept of the hook() function is that it can remove the function...

3 minutes read.

Ceil and Floor in C

In arithmetic, a rational number is a number that can be expressed as the quotient p/q of two integers. Where q is zero. The set of rational numbers includes all...

6 minutes read.

Pointers in C

Pointers in C: In the C programming language, a pointer is a pointer variable that points to the address of the other variable. It also stores the address of the...

4 minutes read.

OpenGL in C

OpenGL stands for Open Graphics Library. It is a low-level, widely supported modeling and rendering software package that is widely available across all the platforms. It is an API used...

4 minutes read.

If Statement in C

Decision Control Statements We frequently desire one set of instructions to be carried out in one circumstance while another set of instructions to be carried out in a completely different circumstance....

3 minutes read.

Bank Account System in C using File Handling

This tells about the creation of bank account system using the C language and handling of files in C. Approach Let us see the approaches and the functions how they are covering...

5 minutes read.

memmove() in C

Introduction: In this article we are discuss about the memmove() function in C. This function transfers memory blocks from one location to another. The memmove() function is declared in the...

3 minutes read.

Distance Vector Routing Protocol Program in c

A distance-vector routing protocol is one of the foremost instructions of routing protocols in pc conversation principle for packet-switched networks. The hyperlink-nation protocol is the alternative foremost class.The Bellman-Ford set...

4 minutes read.

Pointer to pointer in C

A pointer to another pointer is another type of multiple indirections and a chain of many pointers. Generally, a pointer consists of the address of the variable. Once a pointer to...

4 minutes read.

C Program Swap Numbers in cyclic order Using Call by Reference

The three integers that the user entered in cyclical sequence are swapped in this tutorial using call by reference. C Program: #include <stdio.h> void cyclic_Swap ( int *X, int *Y, int *Z ); int...

2 minutes read.

FIFO Example in the C Language

FIFO is an acronym that means "First In, First Out." It is a data structure handling method in which the first element is handled first, and the last element is...

3 minutes read.

Function in C

Function is a group of statements that are used to perform any task. In other words, we can say that a function is a self- contained a block of programs...

3 minutes read.