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 6578505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:46:46+00:00 2026-05-25T15:46:46+00:00

I don’t really know about C. So, my questions and ideas may be misleading

  • 0

I don’t really know about C. So, my questions and ideas may be misleading or ridiculous or embarrassing. Please forgive me..

The question states that the program should get the user input from the command prompt. the input text will have numbers, alphabets and space characters. they will have multiple lines too..

The example program is using <stdio.h> and hence printf and scanf.

Using cin and cout is not encouraged according to the textbook. In order to use cin and cout, I need <iostream> but I can’t include <iostream>. Even if I could include <iostream>, but I then can’t include <stdio.h> anymore.

I also can’t use string. I’ve heard that C doesn’t allow the use of string, but I don’t really understand why.


My question is; when you ask users to type in something with printf("Enter your text: ");, they can only type in one line.. once they hit Enter, the program receive it.

Is there anyway to use scanf to allow users to type in multiple lines by typing Shift+Enter for example.

As string is not available, should I use a char array like char inputText[999]? Will this give me enough space?

My two questions are; How to allow users to type multiple lines in command prompt, and what data type should I use to save the entered text?

I googled it but they mix C++ and C..

Thanks to all and once again, i apologize if my question is a waste of time for you..

Hi all, I have done it.. but I only have one more problem..

#include <stdio.h>
#include <stdlib.h>

int nc=0,nw=0,bs=0,c, nq=0, nl=0;
int main()
{
    printf("Text Analysis Program\n\n");
    printf("Enter your text:");
    while((c=getchar())!=EOF)
    {
        if( (c>='A' && c<='Z') || (c>='a' &&  c<='z') )
        {
            nc++;
        }
        else if( c>='0' && c<='9' )
        {
            nq++;
        }
        else if (c==' ')
        {
            nw++;
            bs++;       
        }
        else if (c=='\n')
        {
            nw++;
            nl++;
        }
    }
    printf("Number of characters: %d;\n",nc);
    printf("Number of words: %d;\n",nw);
    printf("Number of numerical quantities: %d;\n",nq);
    printf("Number of blank spaces: %d;\n",bs);
    printf("Number of lines entered: %d;\n",nl);
    exit(0);
}

At the end, after the answers are shown, cmd screen closes straight away.. I removed exit(0) it is still the same. Is there any commands to freeze the screen and appears Press any key to continue

  • 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-25T15:46:47+00:00Added an answer on May 25, 2026 at 3:46 pm

    Just add another getchar() call:

    #include <stdio.h>
    
    int main() {
      printf("Press any key to continue. ");
      fflush(stdout);
      getchar();
      return 0;
    }
    

    It actually doesn’t return until you type a full line or it hits EOF but it should be good enough.

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

Sidebar

Related Questions

don't know if the title describes anything about what I'm trying to say but
Don't really know how to formulate the title, but it should be pretty obvious
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Don't know if I worded the question right, but basically what I want to
Don't know if this has been asked before, so point me to another question
I don't know if this question is trivial or not. But after a couple
Don't know a whole lot about streams. Why does the first version work using
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Don't know if it matters, but the msg.d is about 300 rows long. I
Don't know much about encryption... Say I'm preparing a SAML request to submit to

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.