小编Joe*_*Joe的帖子

为什么所有cout和cin的"未声明的标识符

在我的main.cpp中,我的所有cout和cin都有错误.

/**
* Description: This program demonstrates a very basic String class.  It creates
* a few String objects and sends messages to (i.e., calls methods on)
* those objects.
*
*/
//#include <iostream>
#include "mystring.h"
//using namespace std;

/* Function Prototypes */

void Display(const String &str1, const String &str2, const String &str3);


/*************************** Main Program **************************/

int main()
{
  String str1, str2, str3;   // Some string objects.
  char s[100];               // Used for input.

  // Print out their initial values... …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
1万
查看次数

2使用strcmp函数测试失败

下面的代码在我的头文件中:

int mystrcmp(const char *s1, const char *s2) // strcmp function
{
    while(*s1 == *s2)
    {
        if(*s1 == '\0' || *s2 == '\0')
            break;

        s1++;
        s2++;
    }

    if(*s1 == '\0' && *s2 == '\0')
        return (0);
    else
        return (-1);
}
Run Code Online (Sandbox Code Playgroud)

问题是,当我运行它时,我的main.cpp表示它未通过2次测试

以下是我的main.cpp的摘录:

void testmystrcmp(void)
{
   int iResult;

   iResult = mystrcmp("Ruth", "Ruth");
   ASSURE(iResult == 0);

   iResult = mystrcmp("Gehrig", "Ruth");
   ASSURE(iResult < 0);

   iResult = mystrcmp("Ruth", "Gehrig");
   ASSURE(iResult > 0);  // right here mystrcmp fails the test

   iResult = mystrcmp("", "Ruth");
   ASSURE(iResult …
Run Code Online (Sandbox Code Playgroud)

c++ strcmp

0
推荐指数
1
解决办法
437
查看次数

标签 统计

c++ ×2

strcmp ×1