Q
Q
Qubc2016-07-19 17:28:27
C++ / C#
Qubc, 2016-07-19 17:28:27

Datle Paul, C, identify the numbers corresponding to the symbols?

C uses small numbers to represent characters internally. Determine the numbers corresponding to ABC abc 0 1 2 $ + /
It doesn't work. It is clear that there is no need to define the data type of the digits - 0, 1, 2.
It is clear that you need to declare ABC abc $ - although it does not matter here what type they belong to.
#include
main()
{
int A, B, C, a, b, c, $;
printf("A=%d\nB=%d\nC=%d\na=%d\nb=%d\nc=%d\n", A, B, C, a, b, c);
printf("$=%d\n0=%d\n1=%d\n2=%d\n", $, 0, 1, 2);
return 0;
}
A=2130567168
B=2686756
C=4194432
a=4200592
b=4200686
c=2686824
$=4200592
0=0
1=1
2=2
How to do the same with * + / ???

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abcd0x00, 2016-07-20
@abcd0x00

Study this code. And take a normal book first (K&R2), which explains why int is used for characters, not char.

The code
#include <stdio.h>

int main(void)
{
    int c;

    printf("%c %d %x\n", 'a', 'a', 'a');
    printf("%c %d %x\n", 'b', 'b', 'b');
    printf("%c %d %x\n", '$', '$', '$');

    c = 'A';
    printf("%c %d %x\n", c, c, c);
    c = '+';
    printf("%c %d %x\n", c, c, c);
    c = '/';
    printf("%c %d %x\n", c, c, c);

    return 0;
}

Вывод
[[email protected] c]$ .ansi t.c -o t
[[email protected] c]$ ./t
a 97 61
b 98 62
$ 36 24
A 65 41
+ 43 2b
/ 47 2f
[[email protected] c]$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question