库库尔坎2011
发表于 2012-11-3 15:19:36
能免费下载就好了。
hugfish
发表于 2012-12-6 13:57:28
好贵啊。。30个。。
ゅツ慮契な
发表于 2013-1-3 16:29:52
感谢小甲鱼
根深蒂固
发表于 2013-1-3 22:30:45
#include <iostream>
#include <fstream>
#include <windows.h> // 为了使用Sleep()函数
struct FishOil
{
std::string name;
std::string uid;
char sex;
};
bool InitFishC();
bool ReadFishC();
void RecordFishC();
bool WriteFishC(FishOil *OilData);
int main()
{
int i;
InitFishC();// 初始化数据。
while( 1 )
{
std::cout << "请选择需要进行的操作: \n";
std::cout << "1. 打印数据到屏幕\n";
std::cout << "2. 录入数据\n";
std::cout << "3. 退出程序\n";
std::cin >> i;
switch( i )
{
case 1:
if( ReadFishC() )
std::cout << "成功读取文件^_^\n\n";
else
std::cout << "读取文件失败T_T\n\n";
break;
case 2:
RecordFishC();
break;
case 3:
return 0;
}
}
std::cout << "初始化失败T_T......\n\n";
return 0;
}
bool InitFishC()
{
FishOil OilInit = {"小甲鱼", "fishc00001", 'M'};
if( WriteFishC(&OilInit) == false )
std::cout << "初始化失败T_T\n";
}
bool ReadFishC()
{
std::string temp;
std::ifstream fileInput("FishC.txt");
if(fileInput.is_open() )
{
std::cout << "\n正在输出记录数据...... ";
for( int i=0; i <= 100; i++ ) // 打印百分比
{
std::cout.width(3);
std::cout << i << "%";
Sleep(50);
std::cout << "\b\b\b\b";
}
std::cout << "\n\n";
std::cout << " 姓名 " << "身份证" << " 性别 " << "\n\n";
while( std::getline( fileInput, temp ) )
{
std::cout << temp << " ";
std::cout << "\n";
}
std::cout << "\n\n";
return true;
}
else
return false;
}
void RecordFishC()
{
char goon, Save;
FishOil OilData;
FishOil *pOilData;
goon = 'Y';
while( 'Y' == goon )
{
std::cout << "请输入鱼C账号: ";
std::cin >> OilData.name;
std::cout << "请输入鱼C身份证:";
std::cin >> OilData.uid;
std::cout << "请输入性别:";
std::cin >> OilData.sex;
std::cout << "录入成功, 请问需要保存吗?(Y/N)";
std::cin >> Save;
if( 'Y' == Save )
{
pOilData = &OilData;
if( WriteFishC( pOilData ) )
std::cout << "成功写入文件^_^\n";
else
std::cout << "写入文件失败T_T\n";
}
else
{
return;
}
std::cout << "/n请问需要再次录入吗?(Y/N)";
std::cin >> goon;
}
}
bool WriteFishC( FishOil *pOilData )
{
std::ofstream fileOutput("FishC.txt", std::ios::app);
// std::ios::app用来说明在老数据追加新数据
if( fileOutput.is_open() )
{
fileOutput << pOilData->name << " ";
fileOutput << pOilData->uid << " ";
fileOutput << pOilData->sex << "\n";
fileOutput.close();
std::cout << "数据成功保存到FishC.txt\n\n";
}
else
std::cout << "保存失败T_T\n";
}
--------------------Configuration: fishoil - Win32 Debug--------------------
Compiling...
fishoil.cpp
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(54) : error C2552: 'OilInit' : non-aggregates cannot be initialized with initializer list
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(80) : error C2039: 'getline' : is not a member of 'std'
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(80) : error C2065: 'getline' : undeclared identifier
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(82) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no accepta
ble conversion)
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(103) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no accept
able conversion)
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(105) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no accept
able conversion)
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(135) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no accept
able conversion)
G:\实验程序\c程序\C++\fishoil\fishoil.cpp(136) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no accept
able conversion)
Error executing cl.exe.
fishoil.obj - 8 error(s), 0 warning(s)
怎么解决???????????
JiaY
发表于 2013-1-8 00:20:26
额。。。为什么论坛上的东西一般都要积分呢?
kit1858644
发表于 2013-1-18 03:36:41
没有鱼币:'(
ADMIRAL
发表于 2013-1-28 20:22:43
30鱼币啊 怎么获取鱼币啊。。甲鱼哥哥
1139146183
发表于 2013-1-29 15:26:41
哎呀,太贵了
liyong2003
发表于 2013-2-5 20:34:18
这个好贵呀。要30鱼币,钱完全不够的说。
liyong2003
发表于 2013-2-5 22:21:47
这段代码放在vs2012中编译会报错。但用g++编译就不会。这是为什么呢?
流☆水
发表于 2013-2-12 20:49:24
这个程序憋了好久勒= =。可惜鱼币不够啊
流☆水
发表于 2013-2-16 16:59:10
根深蒂固 发表于 2013-1-3 22:30 static/image/common/back.gif
#include
#include
#include // 为了使用Sleep()函数
加上#include<string>
bafengao
发表于 2013-2-16 17:53:17
小甲鱼的视频 坚决支持
渺渺烟淡淡云
发表于 2013-2-27 16:58:59
谢谢分享,来支持下~~~
少波波波波少
发表于 2013-3-11 12:33:07
没鱼币。。。茂名老乡。。。。。
风小朔
发表于 2013-3-14 22:30:26
鱼币太贵了
“Hello__World
发表于 2013-3-28 16:25:59
鱼币赚死我啊
545242883
发表于 2013-4-4 16:56:02
鱼币就一百,扣了就木有 了
willjhw
发表于 2013-5-9 11:01:44
还是蛮贵的
Ubuntu_
发表于 2013-5-10 21:13:20
强烈支持楼主ing……
页:
1
[2]
3
4
5
6
7
8
9
10