输入流与字符串流在CL过程有WARNING,不知问题所在,请赐教!!!!

yakult 2007-08-30 07:04:08
在命令行cl时,会出现warning: E:\Program\Microsoft Visual Studio\VC98\include\istream(41) : while comp
iling class-template member function 'bool __thiscall std::basic_istream<char,st
ruct std::char_traits<char> >::ipfx(bool)'
E:\Program\Microsoft Visual Studio\VC98\include\istream(46) : warning C4530: C++
exception handler used, but unwind semantics are not enabled. Specify -GX
...........................

程序如下:
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;
string a, b;

int dist( );
int min(int a, int b, int c);

void main()
{
ifstream input("input.txt");
ofstream output("output.txt");

getline(input, a);
getline(input, b);

int d = 0;
d = dist();

output<< d;
input.close();
output.close();
}

int dist( )
{
int m = a.size();
int n = b.size();
int i = 0, j = 0 ;

if (n == 0)
return m;
if (m == 0)
return n;

//using namespace std;
vector < int > d(n + 1, 0 );
for ( i = 1; i <= n; i++)
d[i] = i;
for ( i = 1; i <= m; i++)
{
int y = i - 1;
for (j= 1; j <= n; j++)
{
int x = y;
y = d[j];
int z = j > 1 ? d[j - 1]:i;
int del = a[i - 1] == b[j - 1] ? 0:1;
d[j] = min(x + del, y + 1, z + 1);
}

}
return d[n];
}

int min(int a, int b, int c)
{
int min = a;
if ( b < min )
min = b;
if( c < min )
min = c;
return min;
}
...全文
126 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
gfxiang 2007-08-30
  • 打赏
  • 举报
回复
warning提示信息已经说的很清楚了呀。你加上-GX选项就没有这些warning了
yakult 2007-08-30
  • 打赏
  • 举报
回复
程序里没有问题吗?
那些警告是iostream,string的,如何修改程序呢?
gfxiang 2007-08-30
  • 打赏
  • 举报
回复
cl -GX xx.cpp

64,642

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧