Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi ich hab wieder ein simples Problem -> für EUCH ;)

Ich möchte die zeit mit time.h auslesen lassen habe auch schon in meine c++ referenz geschaut und da steht ne funktion mit asctime()

aber ich habe keine ahnung ob unter diese Funktion noch etwas bestimmtes drunter geschreiben werden muss!?

Oder wie soll ich sonst die Zeit auslesen (also die wirkliche zeit di im moment so abläuft ;)

dangö WhiteScar

asctime liefert Dir die Zeit als String, die das Argument (ein const tm*) beinhaltet. asctime gibt nichts aus, und kann auch selbst nicht die aktuelle Zeit bestimmen. Die Zeit muss im Argument bereits drinstehen.

Du musst Dir also vorher die aktuelle Zeit beschaffen, in eine Form umwandeln, mit der asctime umgehen kann, und danach den erhaltenen String ausgeben.

Ich zitiere aus der MSDN:

#include <time.h>
#include <stdio.h>

struct tm *newtime;
time_t aclock;

void main( void )
{
time( &aclock ); /* Get time in seconds */

newtime = localtime( &aclock ); /* Convert time to struct */
/* tm form */

/* Print local time as a string */
printf( "The current date and time are: %s", asctime( newtime ) );
}[/code]

jo danke erstamal für den Source Code ;) hab ihn jetzt ein wenig umgeschrieben weil ich ja mit c++ builder arbeite wenn ich die analoge uhr fertig habe kann ich die ja mal hier posten ;) hier der veränderte source code


//---------------------------------------------------------------------------

#include <vcl\vcl.h>

#pragma hdrstop


#include "Zeit1.h"

#include "time.h"

#include "stdio.h"

//---------------------------------------------------------------------------

#pragma resource "*.dfm"

TForm1 *Form1;

struct tm *newtime;

time_t aclock;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

	: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

time( &aclock );

newtime = localtime( &aclock );

Label1->Caption = asctime( newtime );

}

//---------------------------------------------------------------------------

jo nochmals danke für den code ;)

greez WhiteScar

jaja ich weiß eigentlich soll man das alles sich selber erarbeiten aber trotzdem frage ich hier: Ich hab ja jetzt das Datum, das jahr und den tag mit in meiner ausgabe, das muss irgendwie wech ;) ich brauch nur Stunde,Minute,Sekunde hab mir auch schon ein wenig gedanken drüber gemacht und gesucht und was mit tm_hour, tm_min und TM_sec gefunden aber wie wende ich das wieder an???

danke wenn mir einer weiterhelfen kann ! ;)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.