求解一条C++题目 。。。。。。。
来源:百度知道 编辑:UC知道 时间:2024/05/31 09:34:03
从键盘度入五个人的名字 并存到dat文档中(要出现副函数) 且要显示例如:
xiao wang
屏幕输出:the function(tip: 副函数) is 1 time called
xiao bai
屏幕输出:the function(tip: 副函数) is 2 time called
。。。
程序的开始部分已给出
#include<iostream>
#include<fstream.h>
#include<string.h>
Using namespace std;
//Place the function declaration (prototype) below this line
void main(void)
{
char name[50];
ofstream fout("A:\\names.dat");//change the path of the file if necessary
for(int i=1;i<=5;i++)
{
// insert a statement below to call the function you write and keep the returned string
// in the character array name[50]
fout<<name<<endl;
}
fout.close();
}
xiao wang
屏幕输出:the function(tip: 副函数) is 1 time called
xiao bai
屏幕输出:the function(tip: 副函数) is 2 time called
。。。
程序的开始部分已给出
#include<iostream>
#include<fstream.h>
#include<string.h>
Using namespace std;
//Place the function declaration (prototype) below this line
void main(void)
{
char name[50];
ofstream fout("A:\\names.dat");//change the path of the file if necessary
for(int i=1;i<=5;i++)
{
// insert a statement below to call the function you write and keep the returned string
// in the character array name[50]
fout<<name<<endl;
}
fout.close();
}
#include<iostream>
#include<fstream.h>
#include<string.h>
Using namespace std;
//Place the function declaration (prototype) below this line
void myfunction(char *name, int times)
{
scanf("%s", name);
printf("the function is %d time called\n ", times);
}
void main(void)
{
char name[50];
ofstream fout("A:\\names.dat");//change the path of the file if necessary
for(int i=1;i<=5;i++)
{
// insert a statement below to call the function you write and keep the returned string
// in the character array name[50]
myfunction(name, i);
fout<<name<<endl;
}
fout.close();
}