top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why char is present in C language?

+2 votes
606 views

My second query-
Why char is present in C language, in C for all practical purpose we use char as unsigned int with one byte, then why this is present in C/C++?

posted Sep 29, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
I dint get your question.. Please be more precise about this question.
char is present in any language for the ease of use only, for the simple reason because it is close to the human understanding.

In most of the companies internal coding guild lines you never has such things called char u always use u_int8 or u8 or something similar. As Arshad pointed out confirmation can come only from "Sir Dennis Ritchie"

2 Answers

+2 votes

Why char is present in C language? This a question can only be explained by the creator of C language,
"Sir Dennis Ritchie", why he include char in the C language.

As per my view:
They need some data type to represent different types of values( integer, float, boolean etc)
As we know the smallest possible will be a character which size is one, the smallest size possible.

char : (explanation) smallest addressable unit of the machine that can contain basic character set. It is an integer type. Actual type can be either signed or unsigned depending on the implementation.

Hope you understand.
Thanks :)

answer Sep 29, 2014 by Arshad Khan
0 votes

Char is a datatype which represents a character value.
The char telling the computer to interpret the 65 as a character, not as a number. It is going to give the character output of the equivalent of the number 65 (It should be the letter A for ASCII).
%c is the format code for printing a single character

Hopefully this will solve your problem.
Please correct me, If I am wrong

answer Sep 29, 2014 by Aarti Jain
...