我需要此作业的帮助,它来自针对新学习者的计算机编程课程。这是一个字符数组C++代码被破坏,我必须修复它。除此之外,我现在已经停留很长时间了,我想要一些帮助。如果有人能帮我弄清楚这真的太棒了!谢谢!只是为了笑容C++字符数组,将字符作为输入向后放置
#include"stdafx.h"
#include<iostream>
#include<string>
using namespace std;
int main()
{
string word[20];
char inputword;
int x;
cout<<"Enter a word ";
cin>>inputword;
if(word[0] = 'a' || word[0] = 'e' || word[0] = 'i' ||
word[0] = 'o' || word[0] = 'u')
cout<<"Words that start with vowels are not easily translated to Pig Latin"<<endl;
else
{
cout<<"In Pig Latin: ";
while(word[x] != NULL)
{
cout<<word[x];
++x++;
}
cout<<word[0]<<"ay"<<endl;
}
}
使用'=='在C++中测试相等性,'='表示赋值。 –
1)它有什么问题,2)你到目前为止做了什么? – immibis
你需要做很多改变。当在if()中使用'word []'时,它仍然是未定义的。另外,当你将它用作'char'时,'word []'的类型是'string'。 –