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.

zeit

Empfohlene Antworten

Veröffentlicht

hallo, ich möchte einem string mit sprintf(name","blabla_");

die aktuelle uhrzeit im format HHMMSS und dass datum in YYYYMMDD anhängen....wie mach ich das...??

Die funktion _strtime(tmpbuf) speichert in dem string tmpbuf die Zeit im Format HH:MM:SS

und die funktion _strdate(tmpbuf) macht das selbe mit dem Datum im Format MM/DD/JJ

Das kannst du ja zu dem bauen was du brauchst und mit sprintf() kannst du ja diese beiden strings zu einem zusammenbauen:

sprintf(ziel, "%s %s", strTime, strDate)

genau diese antwort wollt ich hören ...

ein herzliches dankeschön an sloenig

genau diese antwort wollt ich hören ...

Sicher?

Als Ansatz für weitere Verbesserungen (z.B. Parameterchecks, prüfen, ob die Ausgabebuffer auch groß genug sind, usw.):


#include <time.h>


void date2char(char *buf, struct tm *timeptr)

{

	// YYYYMMDD

	sprintf(buf,"%i%02i%02i", 1900+timeptr->tm_year, 1+timeptr->tm_mon, timeptr->tm_mday);

}


void time2char(char *buf, struct tm *timeptr)

{

	// HHMMSS

	sprintf(buf,"%02i%02i%02i", timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec);

}


int main(int argc, char* argv[])

{

	char date_s[9];

	char time_s[7];

	time_t now;

	struct tm *now_tm;

	time(&now);

	now_tm = localtime(&now);

	date2char(date_s, now_tm);

	time2char(time_s, now_tm);

	printf("Date: %s\nTime: %s\n", date_s, time_s);

	return 0;

}

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.