Güncelleme: Herkese hızlı yanıtlarınız için teşekkürler - sorun çözüldü!C++ - beklenen birincil ifade ''
C++ ve programlama konusunda yeniyim ve anlayamadığım bir hatayla karşılaştım. Ben program çalıştırmayı denediğimde şu hata mesajını alıyorum: Ben de fonksiyonlara atamadan önce ayrı bir satırda değişken tanımlama denedim
stringPerm.cpp: In function ‘int main()’:
stringPerm.cpp:12: error: expected primary-expression before ‘word’
ama aynı hata mesajı alıyorum sonunda .
Bu konuda herhangi bir tavsiye önerisi olan var mı? Şimdiden teşekkürler! Aşağıda
bakınız kodu:
#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 sözcük uzunluğu = wordLengthFunction (kelime); Yardımlarınız için' –