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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:49:13+00:00 2026-06-02T13:49:13+00:00

#include <stdio.h> int main() { char _char = 32; int x, p, i, d;

  • 0
#include <stdio.h>

int main()
{
    char _char = 32;
    int x, p, i, d;
    scanf("%d ", &x);
    while(_char == 32)
        _char = getchar();
    x = x%26;
    printf("The encrypted string is: ");
    while((_char >= 'a' && _char <= 'z') || (_char >= 'A' && _char <= 'Z'))
    {
        if(_char >= 'a' && _char <= 'z')
            _char = 'a' + (_char + x - 'a')%26;
        else
            _char = 'A' + (_char + x - 'A')%26;
        d = 'a' - 'A';
        p = (_char >= 'a') ? _char - d : _char + d;
        printf("%c", p);
        scanf("%c", &_char);
    }
    return 0;
}

Code description : the program receives a number ‘x’ followed by spaces and then a sequence of letters , then it will print these letters (modified) until the first number or when there is no more letters to receive . It works fine when I run it in Code blocks but when I use CMD to insert the inputs as a file , this gives me an infinite loop if I insert :

1   FffF 

when I add 0 or any number it works fine :

1   FffF0

the infinite loop is sth like :

The encrypted string is:
BBBcccDDDeeefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz....

how can I slove this !?

  • 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-06-02T13:49:16+00:00Added an answer on June 2, 2026 at 1:49 pm

    If there is no more input to scan,

     scanf("%c", &_char);
    

    doesn’t modify _char. You have to check the return value of the scan,

    if (scanf("%c",&_char) < 1) break;
    

    to exit the loop then.

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

Sidebar

Related Questions

#include <stdio.h> #include <string.h> int main(){ char *command=0; do { printf([A]dd, [P]rint, [Q]uit\n); scanf(%s,
consider the code #include<stdio.h> int main(void) { char* a; scanf(%s,a);//&a and &a[0] give same
#include <stdio.h> int main() { char read = ' '; while ((read = getchar())
#include <stdio.h> int main () { char loop='y'; while(loop != 'n') { printf(loop? );
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { // int char str[40],ch; FILE*fp,*fp1,*fp2; fp=fopen(ide_input,w); fp1=fopen(error_log,w); fp2=fopen(lex_output,w);
#include<stdio.h> #include<zlib.h> #include<unistd.h> #include<string.h> int main(int argc, char *argv[]) { char *path=NULL; size_t size;
#include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char
#include <stdio.h> #include <string.h> #include <ctype.h> void delspace(char *str); int main() { int i,
#include<stdio.h> int main() { char a[5]=hello; puts(a); //prints hello } Why does the code
#include<stdio.h> int a[100]; int main(){ char UserName[100]; char *n=UserName; char *q=NULL; char Serial[200]; q=Serial;

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.