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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:22:10+00:00 2026-06-15T01:22:10+00:00

char input1; std::cout << input1 : ; std::cin >> input1; int input2; std::cout <<

  • 0
char input1;
std::cout << "input1 : ";
std::cin >> input1;

int input2;
std::cout << "input2 : ";
std::cin >> input2;

std::cout << input1 << std::endl;
std::cout << input2 << std::endl;

return 0;

I wrote ‘a’ at input1 and ‘a’ at input2.

Ouput is like this.
input1 : a
input2 : a
a
-858993460

I’m curious…’a’ charter is 97 in dec. why does it print -858993460?
‘a’ is not converted to 97 automatically? why?

  • 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-15T01:22:12+00:00Added an answer on June 15, 2026 at 1:22 am

    a, as a string, is not convertible to an int by the rules std::cin follows. Consider this: a is not a valid integer in base 10. std::cin will fail to convert the string "a" to an int.

    The reason it prints -858993460 is because the int is not initialized, so it could print anything, or nothing, or do whatever it desires (look up undefined behaviour).

    Try something like this instead:

    char input2_chr;
    std::cin >> input2_chr;
    int input2 = input2_chr;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

consider this code snippet void make(int n) { std::string user_input; std::istringstream iss(user_input); char letter;
Given this code: #include <cstdio> #include <iostream> #include <string> using std::cin; using std::cout; using
#include<iostream> using namespace std; int main() { char arr[200]; while(1) { cin >> arr;
#include <iostream> #include <ctype.h> using namespace std; void isPalindrome(); int main() { char response;
i wrote the following code.... #include< iostream> #include< fstream> using namespace std; int main()
I make this program :: #include<stdio.h> char *raw_input(char *msg); main() { char *s; *s
#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);
char imei_temp[14] = {0, }; strcpy(imei_temp, 00000000000000); According to my understanding this is valid
char c='c'; int i=10; double d =50; long l=30; String s=Goodbye; Are these statement
The following code: char filename[64]; ifstream input; cout << Please enter the filename: <<

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.