Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Tech Answered Logo Tech Answered Logo
Sign InSign Up

Tech Answered

Tech Answered Navigation

  • Home
  • Tutorials
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us
Home / Questions /Q 1176
Next
In Process
Rekha kumari
Rekha kumari

Rekha kumari

  • India
  • 1 Question
  • 2 Answers
  • 0 Best Answers
  • 25 Points
View Profile
  • 0
Rekha kumari
Asked: December 15, 20202020-12-15T12:43:03+05:30 2020-12-15T12:43:03+05:30In: C Language

How to print all characters from a string in C.

  • 0

I want to print characters only from input string
If input contains characters, numbers and special symbols then output contain characters only. For example if input string is ” Shi&+358@57rek” Then output will be “shirek”.

Will anyone please help me?

c program only to print characters
  • 1
  • 1,054
  • 0
  • 0
Answer
Share
  • Facebook

    Related Questions

    • code for matrix multiplication in c
    • c keep asking for input how to write a program that asks user input
    • How do you find the factorial of a number in C using while loops?
    • What Is A "null Pointer Assignment" Error? What Are Bus Errors, Memory Faults, And Core Dumps?
    • What is OOPs concept in C++ with examples?
    • What is the use of github?
    • How to fix broken commit

    1 Answer

    1. Nadiminti Naga Satya Veni
      2021-07-27T13:45:10+05:30Added an answer on July 27, 2021 at 1:45 pm

      Here,is the program to print only characters from a string.If input contains characters,numbers and special symbols in C Language:

      #include <stdio.h>

      int main() {
      char line[150];

      printf(“Enter a string: “);
      fgets(line, sizeof(line), stdin); // take input

      for (int i = 0, j; line[i] != ‘\0’; ++i) {

      // enter the loop if the character is not an alphabet
      // and not the null character
      while (!(line[i] >= ‘a’ && line[i] <= ‘z’) && !(line[i] >= ‘A’ && line[i] <= ‘Z’) && !(line[i] == ‘\0’)) {
      for (j = i; line[j] != ‘\0’; ++j) {

      // if jth element of line is not an alphabet,
      // assign the value of (j+1)th element to the jth element
      line[j] = line[j + 1];
      }
      line[j] = ‘\0’;
      }
      }
      printf(“Output String: “);
      puts(line);
      return 0;
      }

      In Above Program,It takes a string input from the user and stores in the variable line. And then a for loop is used to interate over the characters of the input string.If the characters in a string are not an alphabet,then it will remove from the given input string and position of the remaining characters are shifted to the left side one by one

      I Hope this answer helped you.

      Thank you!

      • 1
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    More Questions

    • glenn

      code for matrix multiplication in c

    • Tech savvy

      c keep asking for input how to write a program

    • Mingle tap

      How do you find the factorial of a number in

    • Namrata

      What Is A "null Pointer Assignment" Error? What Are Bus

    • Hari

      What is OOPs concept in C++ with examples?

    • Samakshi baghel

      What is the use of github?

    • Samakshi baghel

      How to fix broken commit

    • shree

      in turbo c how to change the cursor

    Stats

    • Questions 1,990
    • Answers 2,103
    • Posts 12
    • Best Answers 73

    Related Questions

    • glenn

      code for matrix multiplication in c

    • Tech savvy

      c keep asking for input how to write a program that asks

    • Mingle tap

      How do you find the factorial of a number in C using

    • Namrata

      What Is A "null Pointer Assignment" Error? What Are Bus Errors, Memory

    • Hari

      What is OOPs concept in C++ with examples?

    • Samakshi baghel

      What is the use of github?

    • Samakshi baghel

      How to fix broken commit

    • shree

      in turbo c how to change the cursor

    Explore

    • Home
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help

    Footer

    Recent Comments

    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • AaronBlackburn on why can’t i find my message requests on instagram
    Ask A Question

    Archives

    Tags

    laptop buying guide (1) limit google news notifications (1) printer buying guide (1) stop google news notifications (1) turn off google news notifications (1)

    Social media

    © 2023 @ Techanswered.com.
    Terms, Privacy policy & Sitemap.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.