#9331: 會出現CE


b9802104 (b9802104)

學校 : 不指定學校
編號 : 44891
來源 : [110.27.170.209]
最後登入時間 :
2014-12-01 15:46:48
a009. 解碼器 -- ACM 458 | From: [114.38.17.2] | 發表日期 : 2014-10-18 14:08

 我在自己dev c跑得過
但放來這邊就會出錯 
 
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
  char line[256];
  char a;
  int length;

  while(cin.getline(line,256))
  {
  length = strlen(line);
  for (int i = 0 ; i <= length ; i++)
     {
        a = line[i];
        a -=7;
        cout << a;
     }
  cout << endl;
  }

//    system("PAUSE");
    return EXIT_SUCCESS;
}
 
------------------------------------------------------------------------------------- 
/code_2019287.cpp: In function ‘int main()’: 
/code_2019287.cpp:16:23: error: ‘strlen’ was not declared in this scope 
 
#9332: Re:會出現CE


gtyuse (gtyuse)

學校 : 國立科學工業園區實驗高級中學
編號 : 37104
來源 : [140.112.215.56]
最後登入時間 :
2021-02-18 08:23:14
a009. 解碼器 -- ACM 458 | From: [123.110.232.18] | 發表日期 : 2014-10-18 16:03

/code_2019287.cpp: In function ‘int main()’: 
/code_2019287.cpp:16:23: error: ‘strlen’ was not declared in this scope 

< string > 和 < string.h > 不一樣喔

 

DEVC++ 貌似自己幫你 include 了

所以要加 < string.h > 或 < cstring > 

上面是 ANSI C 的 

而 string 是 C++ 的 STL 

 
ZeroJudge Forum