int main() {
int i, b;
int d = 0;
int base = 1;
std::ifstream ifs("\P:\result.txt"); char ch_a[256]; if (ifs.fail()) { std::cerr << "失敗" << std::endl; return -1; } while (ifs.getline(ch_a, 256 - 1)) { int n = sscanf(ch_a, "%d", &b); while (b>0) { d = d + (b % 10) * base; b = b / 10; base = base * 2; } } printf("10進数 = %d\n", d); printf("文字は%c\n", d); return 0; }
Whlie文の中身の処理がわからなく困っているので解説お願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。