"A"로만 작성된 입력 텍스트가 있고 다음 ASCII 세트 (B)를 생성 할 수있는 일련의 코드가 필요한 경우 어떻게해야합니까?C++ 입출력 텍스트 파일에 대한 초급 질문.?
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include iostream>
#include fstream>
#include iomanip>
#include string>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
string firstName;
string lastName;
string character;
int age;
double rectangle, length, width, area, parameter, circle, radius, areaCircle, circumference, beginningBalance, interestRate, endBalance;
inFile.open("inData.txt");
outFile.open("outData.txt");
outFile << fixed << showpoint;
outFile << setprecision(2);
cout << "Data is processing..." << endl;
inFile >> length >> width;
area = length * width;
parameter = (length * 2) + (width *2);
outFile << "Rectangle:" << endl;
outFile << "Length = " << length << " " << "width = " << width << " " << "area = " << area << " " << "parameter = " << parameter << endl;
inFile >> radius;
outFile << " " << endl;
outFile << "Cricle:" <<endl;
areaCircle = 3.14159 * (radius * radius);
circumference = 2 * (3.14159 * radius);
outFile << "Radius = " << radius << " " << "area = " << areaCircle << " " << "circumference = " << circumference;
outFile << endl;
outFile << endl;
inFile >> firstName >> lastName >> age;
outFile << "Name: " << firstName << " " << lastName << "," << " " << "age: " << age;
outFile << endl;
inFile >> beginningBalance >> interestRate;
outFile << "Beginning balance = " << beginningBalance << "," << " " << "interest rate = " << interestRate << endl;
endBalance = ((18500 * .0350)/12.0) + 18500;
outFile << "Balance at the end of the month = $" << endBalance;
outFile << endl;
inFile >> character;
outFile << "The character that comes after" << character << "in the ASCII set is" << character +1;
inFile.close();
outFile.close();
return 0;
}
"char"를 변수 이름으로 사용하지 마십시오. 그것은 키워드입니다. – Dave
코드를 포맷하려면 코드를 선택하고 101010 패턴이있는 버튼을 사용하십시오. 'this '와 같은 문장 안의 블록 만 포맷하고 싶다면 단일 역 따옴표를 사용하십시오. –
코드를 다시 포맷하십시오. – cpx