ما الفرق بين؟
End of file controlled loop
و
End of file at keyboard?
ا
ما الفرق بين؟
End of file controlled loop
و
End of file at keyboard?
ا
السلام عليكم ،
الفرق بينهم ان الاول تقرأ البيانات من file موجود بالكمبيوتر واذا وصل عند اخر بيان بيتوقف عمل الloop أما الثانية فبحدد اللي كتب الكود فص اذا ضغطه عليه المستخدم يتوقف عمل loop مثل
المثال الاول :
total = 0;
myInfile >> thisBP;
while (myInfile)
{
total = total + thisBP;
myInfile >> thisBP;
}
cout << total;
المثال الثاني :
total = 0;
cout << “Enter blood pressure (Ctrl-Z to stop)”;
cin >> thisBP; // priming read
while (cin = Z ) // while last read successful
{
total = total + thisBP;
cout << “Enter blood pressure”;
cin >> thisBP; // read another
}
cout << total;
تم تعديل هذه المشاركة بواسطة تيمون في 10 أكتوبر 2003 في 17:55
هذا الموضوع مغلق.