Home > Back-end >  C need digital converted to char, int type.
C need digital converted to char, int type.

Time:02-28

# include
Int main ()
{
Char a='9'.
Int b=a - '0';
Printf (" % d ", b);
return 0;
}

CodePudding user response:

Int b=atoi (a) - '0';

CodePudding user response:

Where is your problem

CodePudding user response:

Quite good, the output 9

CodePudding user response:

The original poster is the problem? 0 ~ 9 corresponding ASCII value is val + '0', val of 0 ~ 9

CodePudding user response:

This method is right, where is the problem?

CodePudding user response:

The program no problem!

CodePudding user response:

Beautifully written, there is no problem

CodePudding user response:

Char number converted to type int is you this kind of writing.

CodePudding user response:

Write so good, do not have what problem

CodePudding user response:

Computer memory or file content or transport it is just a one-dimensional binary byte array and its corresponding binary address;
The human brain to a computer memory or file contents or transfer the content of the one-dimensional binary byte array and its corresponding binary address some parts as an integer, number of signed/unsigned number, floating point Numbers, complex Numbers, letters, digits, Chinese/Korean/French... Character/string, assembly instructions, functions, function parameters, heap, stack, arrays, Pointers, array pointer and pointer array, the array of arrays, pointer to pointer, two-dimensional arrays, character lattice, the coordinates of character strokes, black and white binary images and grayscale images, color images, audio, video, fingerprint information, id information...

CodePudding user response:

Reduction before judgment about whether a '0' between '9' 0 '

CodePudding user response:

So writing should be no problem, what are you trying to say?

CodePudding user response:

Very good, there is no problem

CodePudding user response:

Results 9

CodePudding user response:

This is ill-chosen expression, when defining a variable assignment cannot directly to expression

CodePudding user response:

Minus the character 0 can solve this problem

CodePudding user response:

CodePudding user response:

refer to 17th floor layman response:
this is ill-chosen expression, when defining a variable cannot be directly will expression assignment

Can ah,,,,,,,,,,,,,,

CodePudding user response:

reference 1st floor smwhotjay response:
int b=atoi (a) - '0';

Minus 48

CodePudding user response:

Can only is a digit transformation, two or even three
  • Related