#pragma warning (disable:4996)
#include<stdio.h>
int main(void) {
int cnt = 0, digt_cnt = 0, i, total = 0;
char c;
while (c = getchar()) {
if (c == 'q')
return 0;
++cnt;
{if (c >= '0' && c <= 9) ++digt_cnt;
i = 1;
while (i++ <= c) {
if (c == "B")
break;
total += 1;
printf("input = %c and total = %d\n", c, total);
}
}
return 0;
}
}
A program in which ASCII code values are output when characters are entered. However, if you enter A when it is output, for example,
input = A and total = 1
input = A and total = 2
input = A and total = 3
..........
input = A and total = 65
That's what it says. I just want to print out the last value, what should I do?
c for
while (i++ <= c) {
if (c == "B")
break;
total += 1;
printf("input = %c and total = %d\n", c, total);
}
= >
while (i++ <= c) {
if (c == "B")
break;
total += 1;
}
printf("input = %c and total = %d\n", c, total);
I think this will work.
© 2024 OneMinuteCode. All rights reserved.