الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

خطأ في if statement

بدأه msb2012 في 23 ديسمبر 2010 · 3 رد · 499 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بسم الله الرحمن الرحيم

يا اخوان انا لدي هذا البرنامج

قمت بهذه المحاوله و لا توجد errors

و لكن المشكله هي بعد ادخال النص المراد تشفيره او فك تشفيره لا يحد اي شئ

فقط ادخل النص ثم يقول press any key to continue ...

#include <iostream>

#include <cstring>

#include <string>



using namespace std;

int main() {

	string strTarget;

	int choice;



	cout<<"Enter your choice";



	cin>>choice;













	if (choice = 1) {







		cout << "Enter a string to encrypt: ";

		cin >> strTarget;



        getline(cin,strTarget);



        string temp(strTarget);





		int len = strTarget.length();





		char a;

        string strFinal(strTarget);







        for (int i = 0; i <= (len-1); i++)



        {



                a = strTarget.at(i); 



                int b = (int)a; //get the ASCII value of 'a'



                b += 5; //Mulitply the ASCII value by 5







                a = (char)b; //Set the new ASCII value back into the char



                strFinal.insert(i , 1, a); //Insert the new Character back into the string



				 cout << "Encrypted: " << strTarget << endl;





        }

		 string strEncrypted(strFinal, 0, len);



        strTarget = strEncrypted;



	}



	else if (choice = 2) {















		cout << "Enter a string to decrypt: ";

		cin >> strTarget;



        getline(cin,strTarget);



        string temp(strTarget);





		int len = strTarget.length();



        char a;



        string strFinal(strTarget);







        for (int i = 0; i <= (len-1); i++)



        {



                a = strTarget.at(i); 



                int b = (int)a; //get the ASCII value of 'a'



                b -= 5; //Mulitply the ASCII value by 5







                a = (char)b; //Set the new ASCII value back into the char



                strFinal.insert(i , 1, a); //Insert the new Character back into the string





        cout << "Decrypted: " << (strTarget) << endl;



        }

		 string strEncrypted(strFinal, 0, len);



        strTarget = strEncrypted;



	}







	}
#2

استخدم اشاره == للمقارنه بدلاً من =

#3

شكرا لك

تم التعديل و الان اصبحت قادرا على ادخال النص المراد تشفيره ولكن النتيجه لا تظهر

ارجو المساعده

#4

هذه محاوله أخرى عن طريق الكلاسيس

و صارت لي المشكله حيث انه اذا ادخلت الخيار المطلوب لا استطيع دخال النص المراد تشفيره

الحمد لله تم حل المشكله و تطوير البرنامج بنفسي

تم تعديل هذه المشاركة بواسطة msb2012 في 24 ديسمبر 2010 في 20:49

مواضيع مشابهة