C++ (C+;+;)无法打印输出文件(记事本)的字符串 #包括 #包括 #包括 #包括 #包括 #包括 使用名称空间std; 结构测量 {字符名[100]; 智力年龄; 汉字主语; 答案[2][13]; }taker[10]; 结构健康 {双倍重

C++ (C+;+;)无法打印输出文件(记事本)的字符串 #包括 #包括 #包括 #包括 #包括 #包括 使用名称空间std; 结构测量 {字符名[100]; 智力年龄; 汉字主语; 答案[2][13]; }taker[10]; 结构健康 {双倍重,c++,arrays,struct,file-io,output,C++,Arrays,Struct,File Io,Output,(C+;+;)无法打印输出文件(记事本)的字符串 #包括 #包括 #包括 #包括 #包括 #包括 使用名称空间std; 结构测量 {字符名[100]; 智力年龄; 汉字主语; 答案[2][13]; }taker[10]; 结构健康 {双倍重量; 双高; 双倍体重指数; char-BMIcat[100]; 整数标记; }卫生[10]; 结构脑 {半脑; 国际权利; int左; }大脑[10]; ...... 无效名称和日期(调查人员[],国际一级) { Header();//

(C+;+;)无法打印输出文件(记事本)的字符串
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
结构测量
{字符名[100];
智力年龄;
汉字主语;
答案[2][13];
}taker[10];
结构健康
{双倍重量;
双高;
双倍体重指数;
char-BMIcat[100];
整数标记;
}卫生[10];
结构脑
{半脑;
国际权利;
int左;
}大脑[10];
......
无效名称和日期(调查人员[],国际一级)
{   
Header();//Header。

你能怀疑有问题吗?代码能工作吗?如果不能,它到底是如何工作的?到目前为止你尝试了什么(调试器,打印语句…)来自己解决它?代码能工作。但它不能在输出文件(记事本)中打印出接收者的姓名。出现了其他信息,如年龄、BMI等。@FeiXiang嘿,感谢您的来访和评论。我已经解决了问题,代码运行良好。
#include <iostream>     
#include <fstream>      
#include <iomanip>      
#include <stdlib.h>     
#include <string.h>     
#include <conio.h>  
using namespace std;

struct Survey           
{        char name[100];        
         int age;           
         char subject;      
         char answer[2][13];    
}taker[10];
struct Health           
{        double weight;     
         double height;     
         double BMI;        
         char BMIcat[100];  
         int marks;         
}health[10];

struct Brain            
{       char brain;         
        int right;          
        int left;           
}brain[10];


  ......


void NameAndAge(Survey taker[], int i)              
{   
    Header();                                                                               //Header.
    cout << "\t\t" << "Please Enter The Information Below." << endl << endl;            

    cout << "Enter your name\t: ";                      
cin.getline(taker[i].name, 100);    


    cin.ignore(1000,'\n');
    cin.clear();                                                                                        ";                                                          age.
    cin >> taker[i].age;

    system("cls");                                                                                  
}

int main()
{
    char response = 'y';                        
    int oneORboth;
    ofstream outB, outH;
    outB.open("YourResultForBrain.txt");    
    outH.open("YourResultForHealth.txt");                           
    int bil;

    cout << "Enter how many people are going to take the test? ";
    cin >> bil;
    system("cls");

    while(response != 'n')  //Using while loop !n (for repeating survey).
    {
    Header();                                               
    cout << "\t\t\t" << "      Hello And Welcome!" << endl; 
    cout << endl;                                           
    cout << "\t\t\t" << "     Press Enter To Start" ;       
    getch();                                                
    for (int i=0;i<bil;i++)
    {     NameAndAge(taker, i);

   cin>>oneORboth;                                                                      
  system("cls");                                                                            

if(oneORboth == 1)  
{
    Header();                                                                           //Header.
    cout << "\t\t\t" << "There Are Two Categorized Surveys." << endl << endl;           //Information aboutB survey.
    cout << "\t\t" << "   Categories: 1. Health    2. Left-Right Brain" << endl << endl;
    cout << "\nEnter a category: ";                                                     
    cin >> taker[i].subject;
    switch(taker[i].subject)
    {
        case '1':                           
            WeightAndHeight(health,i);      
            HQ(taker, health,i);                
            break;                          

        case '2':                           
            BQ(taker, brain,i);                 
            break;                          
    }
}

if(oneORboth == 2)  //If taker wants to do both surveys.
{   
        HeaderHealth();                                     
        cout << "\t\t\t" << "     First Survey; Health";    
        cout << endl << endl;                               
        cout << "\t\t\t" << "     Press Enter To Start" ;   
        getch();                                            
        WeightAndHeight(health,i);                      
        HQ(taker, health,i);                                
        HeaderBrain();                                      
        cout << "\t\t\t" << "     Second Survey; Brain";    
        cout << endl << endl;                               
        cout << "\t\t\t" << "     Press Enter To Start" ;   
        getch();                                            
        BQ(taker, brain,i);;                                     

}

float m;                            
m = health[i].height / 100;
health[i].BMI = health[i].weight/(m*m); 


if(health[i].BMI < 18.5)
    strcpy(health[i].BMIcat,"Underweight");
if((health[i].BMI >= 18.50) && (health[i].BMI<= 24.99))
    strcpy(health[i].BMIcat, "Normal");
if((health[i].BMI >= 25.00) && (health[i].BMI <= 29.99))
    strcpy(health[i].BMIcat, "Overweight");
if(health[i].BMI >= 30.00)
    strcpy(health[i].BMIcat, "Obese");



if(taker[i].subject == '1')                             
{
    outH<< "Name\t\t: " << taker[i].name << endl;           
    outH << "Age\t\t: " << taker[i].age<< endl;         
    outH << setiosflags (ios::fixed);
    outH << setiosflags (ios::showpoint);               
    outH << setprecision(2);
    outH << "Weight\t\t: " << health[i].weight << endl; 
    outH << "Height\t\t: " << health[i].height << endl; 
    outH << "BMI\t\t: " << health[i].BMI << endl;           
    outH << "BMI Category: " << health[i].BMIcat << endl;
    outH << "Correct Answer: "<<health[i].marks << endl;    

}
if(taker[i].subject == '2')             
{       
    outB << "Name: " <<  taker[i].name << endl; 
    outB << "Age : " << taker[i].age << endl;   

    if(brain[i].right > brain[i].left)              
    {
        outB << endl;
        outB << "You are Right-Brained!" << endl;
        outB << barline << endl;                            
        outB << "The Right Brain:" << endl;
        outB << barline << endl;                            
        outB << "Unique Traits: " << endl;
        outB << "Recognizes faces easily" << endl;
        outB << "Expressive" << endl;
        outB << "Musical" << endl;
        outB << "Reads emotions easily" << endl;
        outB << "Colorful" << endl;
        outB << "Imaginative" << endl;
        outB << "Intuitiove" << endl;
        outB << "Creative" << endl;

    }
    if(brain[i].left > brain[i].right)          
    {
        outB << endl;
        outB << "You are Left-Brained!" << endl;
        outB << barline << endl;                        
        outB << "The Left Brain " << endl;
        outB << barline << endl;                            
        outB << "Unique Traits: " << endl;
        outB << "Language learner" << endl;
        outB << "Logical" << endl;
        outB << "Critical thinker" << endl;
        outB << "Great with numbers" << endl;
                        //Closes brain output.
    }                                   
}

if(oneORboth == 2)  /* TATA */
{
    outH << "Name\t\t: " << taker[i].name << endl;      
    outH << "Age\t\t: " << taker[i].age << endl;            
    outH << setiosflags (ios::fixed);
    outH << setiosflags (ios::showpoint);               
    outH << setprecision(2);
    outH << "Weight\t\t: " << health[i].weight<< endl;  
    outH << "Height\t\t: " << health[i].height<< endl;  
    outH << "BMI\t\t: " << health[i].BMI<< endl;            
    outH << "BMI Category: " << health[i].BMIcat  << endl;
    outH<< "Correct Answer: "<<health[i].marks << endl; 

}
if(oneORboth == 2)  
{
    outB << "Name: " <<  taker[i].name << endl;         
    outB << "Age : " << taker[i].age << endl;           

    if(brain[i].right > brain[i].left)      
    {
        outB << endl;
        outB << "You are Right-Brained!" << endl;
        outB << barline << endl;                            
        outB << "The Right Brain:" << endl;
        outB << barline << endl;                            
        outB << "Unique Traits: " << endl;
        outB << "Recognizes faces easily" << endl;
        outB << "Expressive" << endl;
        outB << "Musical" << endl;
        outB << "Reads emotions easily" << endl;
        outB << "Colorful" << endl;
        outB << "Imaginative" << endl;
        outB << "Intuitiove" << endl;
        outB << "Creative" << endl;

    }
    if(brain[i].left > brain[i].right)      
    {
        outB << endl;
        outB << "You are Left-Brained!" << endl;
        outB << barline << endl;                        
        outB << "The Left Brain " << endl;
        outB << barline << endl;                            
        outB << "Unique Traits: " << endl;
        outB << "Language learner" << endl;
        outB << "Logical" << endl;
        outB << "Critical thinker" << endl;
        outB << "Great with numbers" << endl;

    }
}

}
cout << barline << headline << barline;
cout << endl << endl;
cout << "\t\t\t\t     Retake?" << endl << endl;
cout << barline << barline << barline << endl << endl;

cout << "y for Yes, n for No." << endl; 
cout << "Take survey again?" << endl;   
cin >> response;                        
system("cls");                          

if(response == 'n')                     
Credit();       
outH.close();                   
outB.close();       

return 0;   

 }
}
void NameAndAge(Survey taker[], int i)              
    {   
        Header();                                                                       
        cout << "\t\t" << "Please Enter The Information Below." << endl << endl;            

        cout << "Enter your name\t: ";                                  


    cin.getline(taker[i].name, 100);    
    cin.ignore(1000,'\n');
     cin.clear();   
    cout << "\nEnter your age\t: ";                             
    cin >> taker[i].age;
        system("cls");                                                                                  
    }