【问题标题】:How to store a list in character type array如何将列表存储在字符类型数组中
【发布时间】:2014-02-08 13:17:30
【问题描述】:

我想在字符类型数组中存储一个字母列表,但是出现了一百行的错误,几乎无法阅读,我找不到任何可以做的事情,我将在下面提供我的代码。

#include <iostream>
#include <string>
using namespace std;
int main ()
{
  char alph[]={'A', 'B', 'C', 'D'};

  for (int i=0; i<4; i++)
  {
    cout<<alph[i]<<" ";
  }

  return 0;
}

【问题讨论】:

    标签: arrays character


    【解决方案1】:

    确保您的源代码中没有非 ASCII 字符(尝试将其粘贴到记事本中,然后将其粘贴回编译器)。

    #include <iostream>
    #include <string>
    using namespace std;
    int main ()
    {
      char alph[]={'A', 'B', 'C', 'D'};
    
      for (int i=0; i<4; i++)
      {
        cout<<alph[i]<<" ";
      }
    
      return 0;
    }
    

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 1970-01-01
      • 2016-03-06
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      • 2015-04-17
      • 2021-09-05
      相关资源
      最近更新 更多