
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Assigning multiple characters in an int in C language
The character type data is stored by its ASCII value internally in C or C++. If we want to print a single character as integer, we will get the ASCII value. But when we are trying to print more than one character using a single quote, then it will print some strange output.
Please check the following program to get the idea.
Example
#include <stdio.h> int main() { printf("%d
", 'A'); printf("%d
", 'AA'); printf("%d
", 'ABC'); }
Output
65 16705 4276803
The ASCII of A is 65. So at first it is showing 65 (01000001). Now for AA, it is showing 16705. This is ASCII of 6565 (01000001 01000001) = 16705. For third the value is ABC (01000001 01000010 01000011) = 4276803.
- Related Articles
- Adding characters in values for an existing int column in MySQL?
- Assigning an integer to float and comparison in C/C++
- What are reading and writing characters in C language?
- String replace multiple characters with an asterisk in JavaScript
- Most Profit Assigning Work in C++
- Convert an int to ASCII character in C/C++
- Assigning arrays in Java.
- Difference between const int*, const int * const, and int const * in C/C++?
- How to convert an int to string in C++?
- Finding number of alphabets, digits and special characters in strings using C language
- What is an identifier in C language?
- What is an anagram in C language?
- How to find the size of an int[] in C/C++?
- What do single quotes do in C++ when used on multiple characters?
- Difference between const int*, const int * const, and int const * in C

Advertisements