ويب صور الأخبار مجموعات ترجمة إجابات Gmail المزيد »
المجموعات التي قمت بزيارتها مؤخرا | مساعدة | تسجيل الدخول
الصفحة الرئيسية لمجموعات Google
Inputting HH:MM:SS format
هناك حالياً عدة مواضيع في هذه المجموعة يتم عرضها كأول موضوع. لجعل هذا الموضوع يظهر كأول موضوع، الرجاء إزالة هذا الخيار من المواضيع اﻷخرى.
وقع خطأ في معالجة طلبك. الرجاء حاول مجددا.
تمييز
  6‏ من الرسائل - طي الكل  -  ترجمة الكل إلى اللغة نص مترجم (عرض جميع المصادر الأصلية)
المجموعة التي تقوم بالإرسال إليها هيمجموعة Usenet. الرسائل المرسلة لهذه المجموعة ستجعل بريدك مرئيًا لأي فرد على شبكة الإنترنت
لم يتم إرسال رسالة الرد حتى الآن.
تم النشر الخاص بك بنجاح
 
من:
إلى:
نسخة إلى:
استجابةً إلى:
أضف "نسخة إلى" | أضف "استجابةً إلى" | تحرير الموضوع
الموضوع:
التحقق:
لغرض التحقق من الصحة، يرجى كتابة الحروف التي تراها في الصورة أدناه أو الأرقام التي تسمعها عند النقر فوق رمز وصول ذوي الاحتياجات الخاصة. استمع وإكتب الأرقام التي تسمعها
 
crystal twix  
عرض ملف التعريف   ترجمة إلى اللغة نص مترجم (عرض المحتوى الأصلي)
 خيارات أكثر 8 نوفمبر, 00:08
مجموعات أخبار: comp.lang.c++
من: crystal twix <jonwongfanc...@gmail.com>
التاريخ: Sat, 7 Nov 2009 14:08:57 -0800 (PST)
محلّي: ‏الأحد 8 نوفمبر 2009 00:08‏
الموضوع: ‏Inputting HH:MM:SS format‏
I'm trying to ask the user for a time in the format HH:MM:SS, and I
was wondering what the best way would be to input those values into a
struct that looks like:

struct time {
int hour;
int min;
int sec;

};

Thanks!

يجب تسجيل الدخول قبل إرسال رسائلك.
لنشر رسالة يجب أولاً أن تنضم إلى هذه المجموعة.
يرجى تحديث اسم الشهرة الخاص بك على صفحة إعدادات الاشتراك قبل النشر.
لا يوجد لديك الإذن المطلوب للنشر.
Maxim Yegorushkin  
عرض ملف التعريف   ترجمة إلى اللغة نص مترجم (عرض المحتوى الأصلي)
 خيارات أكثر 8 نوفمبر, 00:33
مجموعات أخبار: comp.lang.c++
من: Maxim Yegorushkin <maxim.yegorush...@gmail.com>
التاريخ: Sat, 07 Nov 2009 22:33:37 +0000
محلّي: ‏الأحد 8 نوفمبر 2009 00:33‏
الموضوع: ‏Re: Inputting HH:MM:SS format‏
On 07/11/09 22:08, crystal twix wrote:

> I'm trying to ask the user for a time in the format HH:MM:SS, and I
> was wondering what the best way would be to input those values into a
> struct that looks like:

> struct time {
> int hour;
> int min;
> int sec;
> };

For parsing there is strftime() function:
http://www.cplusplus.com/reference/clibrary/ctime/strftime/

--
Max


يجب تسجيل الدخول قبل إرسال رسائلك.
لنشر رسالة يجب أولاً أن تنضم إلى هذه المجموعة.
يرجى تحديث اسم الشهرة الخاص بك على صفحة إعدادات الاشتراك قبل النشر.
لا يوجد لديك الإذن المطلوب للنشر.
Maxim Yegorushkin  
عرض ملف التعريف   ترجمة إلى اللغة نص مترجم (عرض المحتوى الأصلي)
 خيارات أكثر 8 نوفمبر, 00:37
مجموعات أخبار: comp.lang.c++
من: Maxim Yegorushkin <maxim.yegorush...@gmail.com>
التاريخ: Sat, 07 Nov 2009 22:37:04 +0000
محلّي: ‏الأحد 8 نوفمبر 2009 00:37‏
الموضوع: ‏Re: Inputting HH:MM:SS format‏
On 07/11/09 22:33, Maxim Yegorushkin wrote:

> On 07/11/09 22:08, crystal twix wrote:
>> I'm trying to ask the user for a time in the format HH:MM:SS, and I
>> was wondering what the best way would be to input those values into a
>> struct that looks like:

>> struct time {
>> int hour;
>> int min;
>> int sec;
>> };

> For parsing there is strftime() function:
> http://www.cplusplus.com/reference/clibrary/ctime/strftime/

Oops, I meant strptime():
http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html

--
Max


يجب تسجيل الدخول قبل إرسال رسائلك.
لنشر رسالة يجب أولاً أن تنضم إلى هذه المجموعة.
يرجى تحديث اسم الشهرة الخاص بك على صفحة إعدادات الاشتراك قبل النشر.
لا يوجد لديك الإذن المطلوب للنشر.
crystal twix  
عرض ملف التعريف   ترجمة إلى اللغة نص مترجم (عرض المحتوى الأصلي)
 خيارات أكثر 8 نوفمبر, 00:52
مجموعات أخبار: comp.lang.c++
من: crystal twix <jonwongfanc...@gmail.com>
التاريخ: Sat, 7 Nov 2009 14:52:46 -0800 (PST)
محلّي: ‏الأحد 8 نوفمبر 2009 00:52‏
الموضوع: ‏Re: Inputting HH:MM:SS format‏
On Nov 7, 2:37 pm, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:

Ok, I read the reference and tried going over the example.  Would I do
something like this?

struct Time {
    int hours, minutes, seconds;

};

const int length = 8;

int main() {

  char time[length];
  char *time;

  cout << "Enter time:";
  cin >> time;
  Time timeStruct = strptime(time, "%H %M %S", &time);

}

Thanks!

يجب تسجيل الدخول قبل إرسال رسائلك.
لنشر رسالة يجب أولاً أن تنضم إلى هذه المجموعة.
يرجى تحديث اسم الشهرة الخاص بك على صفحة إعدادات الاشتراك قبل النشر.
لا يوجد لديك الإذن المطلوب للنشر.
Sam  
عرض ملف التعريف   ترجمة إلى اللغة نص مترجم (عرض المحتوى الأصلي)
 خيارات أكثر 8 نوفمبر, 05:10
مجموعات أخبار: comp.lang.c++
من: Sam <s...@email-scan.com>
التاريخ: Sat, 07 Nov 2009 21:10:14 -0600
محلّي: ‏الأحد 8 نوفمبر 2009 05:10‏
الموضوع: ‏Re: Inputting HH:MM:SS format‏

No, for at least three reasons. strptime returns a char *, and not your
custom Time C++ class, which the standard C library knows nothing about, of
course.

Furthermore, the third argument that strptime() expects to get is a struct
tm *, and not a char **.

Thirdly, you cannot declare two variables named 'time' in the same scope.

  application_pgp-signature_part
< 1K تنزيل

يجب تسجيل الدخول قبل إرسال رسائلك.
لنشر رسالة يجب أولاً أن تنضم إلى هذه المجموعة.
يرجى تحديث اسم الشهرة الخاص بك على صفحة إعدادات الاشتراك قبل النشر.
لا يوجد لديك الإذن المطلوب للنشر.
James Kanze  
عرض ملف التعريف   ترجمة إلى اللغة نص مترجم (عرض المحتوى الأصلي)
 خيارات أكثر 9 نوفمبر, 02:16
مجموعات أخبار: comp.lang.c++
من: James Kanze <james.ka...@gmail.com>
التاريخ: Sun, 8 Nov 2009 16:16:49 -0800 (PST)
محلّي: ‏الاثنين 9 نوفمبر 2009 02:16‏
الموضوع: ‏Re: Inputting HH:MM:SS format‏
On Nov 7, 11:37 pm, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:

> On 07/11/09 22:33, Maxim Yegorushkin wrote:
> > On 07/11/09 22:08, crystal twix wrote:
> >> I'm trying to ask the user for a time in the format
> >> HH:MM:SS, and I was wondering what the best way would be to
> >> input those values into a struct that looks like:
> >> struct time {
> >> int hour;
> >> int min;
> >> int sec;
> >> };
> > For parsing there is strftime() function:
> >http://www.cplusplus.com/reference/clibrary/ctime/strftime/
> Oops, I meant
> strptime():http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html

Not in C++.  That's a Posix extension, so if you're concerned
with portability, you can't use it.

There are several solutions to what he wants to do, depending on
the context and how flexible he wants to be with regards to the
input (exactly two digits for the hour, or one or two digits,
etc.).  Basically, however, I'd start by defining a
    std::istream& operator>>(std::istream& source, time& dest)
function, using sgetc on the input to determine if the next
character was what I wanted.  Depending on how flexible I wanted
to be, I might just read exactly eight characters, validate it
with a regular expression, then use an istringstream to convert
the three numbers; or I'd input a number, check for and extract
the ':', input another number, check for and extract the ':',
and input the third number.

--
James Kanze


يجب تسجيل الدخول قبل إرسال رسائلك.
لنشر رسالة يجب أولاً أن تنضم إلى هذه المجموعة.
يرجى تحديث اسم الشهرة الخاص بك على صفحة إعدادات الاشتراك قبل النشر.
لا يوجد لديك الإذن المطلوب للنشر.
نهاية الرسائل
« الرجوع إلى المناقشات « موضوع أحدث     موضوع أقدم »

إنشاء مجموعة - مجموعات Google - صفحة Google الرئيسية - شروط الخدمة - سياسة الخصوصية
©2009 Google