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

معرفة وقت الجهاز

مغلق
بدأه griseous_eyes في 24 سبتمبر 2004 · 3 رد · 390 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمه الله وبركاته

اريد كتابه برنامج بالستخدام ال C++ يقوم بحساب الفرق بين عمر المستخدم (مدخل) والتاريخ الموجود في نفس الجهاز

المشكله عندي هي في كيفيه معرفه وقت الجهاز

استخدمت ال هيدر فايل time.h وكتبت الكود هذاكبدايه الا انه يظهر لي error

#include<time.h>
int main()
{
	using std::cout;
	using std::cin;
	using std::endl;
	struct tm*local; //pointer to time structure
	time.t;
	t=time(NULL); //stror time in t
	local=localtime(&t); //fill the structure pointed date
	cout<<"The current date is "<<local->tm_mday<<std::endl;
	cout<<"The current month is "<<local->tm_mon<<std::endl;
	cout<<"The current year is "<<local->tm_year<<std::endl;

	return 0;
}

والخطا كما يظهر

error C2228: left of '.t' must have class/struct/union type

الحقيقه هذي المره الاولى التي اتعامل معها مع ال time :(

#2

عفوا

اللذي قصدته معرفة التاريخ الموجود بالجهاز

خطأ مطبعي :)

#3

خذي الكود المعدل :

#include<time.h>
int main()
{


using std::cout;
using std::cin;
using std::endl;
struct tm*local; //pointer to time structure
time_t t;
t=time(NULL); //stror time in t
local=localtime(&t); //fill the structure pointed date
cout<<"The current date is "<<local->tm_mday<<std::endl;
cout<<"The current month is "<<local->tm_mon<<std::endl;
cout<<"The current year is "<<local->tm_year<<std::endl;


cin.get();

return 0;

المشكلة فقط في متغير ال time لديك هو من النوع time_t ,,

banner_60_468.gif

NOTHING IS IMPOSSIBLE

#4

السلام عليكم

مشكور اخوي HGB مشى الحال :)

هذا الموضوع مغلق.

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