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

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

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

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

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

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 471321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:58:27+00:00 2026-05-12T23:58:27+00:00

Here is my code!(sorry for my poor english) #include<stdio.h> int convert(char ch); int main(void)

  • 0

Here is my code!(sorry for my poor english)

#include<stdio.h>

int convert(char ch);

int main(void)
{
     char ch=0;

     while(ch != 'q')
     {
         ch=getchar();
         ch=convert(ch);
         if(ch == -1)
            printf("wrong input");
         else 
            putchar(ch);
            putchar('\n');
     }

     return 0;
}

int convert(char ch)
{
    if(ch>='A' && ch<='Z')
        ch+=32;
    else if(ch>='a' && ch<='z')
        ch-=32;
    else
        return -1;
}

And this code is for changing A to a, z to Z
convert small to capital lettor, or reverse.

but when done, i found something wierd cuz whenever i put a char to the program,

it always return both the result that i expected and another “wrong input”.
and i didnt put anything to my standard input except a charactor and a Enter.

So, here is my question.

The function getchar() or some other like fgetc, fgets recieve a ‘enter’ as a charactor?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:58:27+00:00Added an answer on May 12, 2026 at 11:58 pm

    The function getchar() or some other
    like fgetc, fgets recieve a ‘enter’ as
    a charactor?

    Yes, ‘Enter’ is character 10. You can see this by adding one extra line:

    ch=getchar();
    printf("Received: %d\n", ch);
    ch=convert(ch);
    

    abc
    Received: 97

    Received: 98

    Received: 99

    Received: 10

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
I am sorry about the amount of code here. I have tried to show
Sorry if this is an easy one. Basically, here is my code: MainViewController.h :
Hi sorry still learning here and slow to learning code arguments. Just wondering could
Here is my code: Sorry for the quality and formatting. Basically, what i want
Sorry just found this code here - http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html and the mutex was explained with
I'm making a code that is similar to this: #include <stdio.h> double some_function( double
I have a problem writing to the SD card, here is the code: (Sorry
First than all sorry that I can put code here, the best way is
The script is on jsfiddle here : CODE What it does at the moment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.