求C++程序高手帮我解决assert问题
来源:百度知道 编辑:UC知道 时间:2024/06/19 08:50:58
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <cassert>
#include "math.h"
这是代码的开头部分
int Word::word_distance(Word b)
{
string c,d;
int s,w=0;
c=word_string;
d=b.get_string();
assert(c.length()==d.length());
for (int i=0;i<c.length();i++)
{
s=distance(c.substr(i,1),d.substr(i,1));
w=w+s;
}
return w;
}
Word Word::word_compress(Word b)
{
string c,d,s;
c=word_string;
d=b.get_string();
assert(c.length()==d.length());
for (int i = 0 ; i < c.length() ; i++ )
{
s=s+compress(d.substr(i,1),c.substr(i,1));
}
这是代码中用到assert的部分。每次用C++运行时都是语句 assert(c.length()==d.length()); 这句出现问题, ‘asse
不是把:
cassert中的内容:
只有一行:
#include<assert.h>
assert.h中 的内容:
/***
*assert.h - define the assert macro
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Defines the assert(exp) macro.
* [ANSI/System V]
*
* [Public]
*
****/
#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif
/* Define _CRTIMP */
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
/* Define __cdecl for non-Microsoft compilers */
#if ( !defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif
/* Define _CRTAPI1 (for compatibility with the NT SDK) */
#ifndef _CRTAPI1
#if _MSC_VER >