업데이트 : 빠른 응답을 보내 주셔서 감사합니다 - 문제가 해결되었습니다!C++ - 예상 기본 표현식이 '
저는 C++과 프로그래밍에 익숙하지 않으며 알아낼 수없는 오류가 발생했습니다. 나는이 프로그램을 실행하려고하면, 다음과 같은 오류 메시지가 얻을 : 나는 또한 기능에 할당하기 전에 별도의 행에 변수를 정의하려고했습니다
stringPerm.cpp: In function ‘int main()’:
stringPerm.cpp:12: error: expected primary-expression before ‘word’
을,하지만 난 같은 오류 메시지가 표시 결국 .
누구든지 이에 대한 조언을 제공 할 수 있습니까? 미리 감사드립니다! 아래
참조 코드 :
#include <iostream>
#include <string>
using namespace std;
string userInput();
int wordLengthFunction(string word);
int permutation(int wordLength);
int main()
{
string word = userInput();
int wordLength = wordLengthFunction(string word);
cout << word << " has " << permutation(wordLength) << " permutations." << endl;
return 0;
}
string userInput()
{
string word;
cout << "Please enter a word: ";
cin >> word;
return word;
}
int wordLengthFunction(string word)
{
int wordLength;
wordLength = word.length();
return wordLength;
}
int permutation(int wordLength)
{
if (wordLength == 1)
{
return wordLength;
}
else
{
return wordLength * permutation(wordLength - 1);
}
}
'int wordLength = wordLengthFunction (word);' –