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.

Verknüpfung von Text und einer Variable in MessageBox

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe folgendes Problem:

Ich möchte in einer MessageBox einen kurze Information zurückgeben und dabei Text und eine Variable verbinden. Wie heißt der verflixte Operator, der die beiden verbindet?

Ich hab den Quellcode mal kurz mitgepostet.

<---snip--->

char computer_name[255];

nSize = sizeof( computer_name );

GetComputerName( computer_name, &nSize);

//char user_name[255];

//nSize = sizeof( user_name );

//GetComputerName( user_name, &nSize);

MessageBox(NULL,"Computername:" computer_name,"Information",MB_OK); // um die Stelle geht es eigentlich

<---snap--->

Hoffe, irgenjemand kann mir helfen...

In C gibt es so einen Operator nicht, aber mit strcat() (aus string.h) kann man einen String an einen anderen "hängen":

char computer_name[255];

char final_string[bIG_ENOUGH];

// [...]

strcpy(final_string, "Computername: ");

strcat(final_string, computer_name);

Man könnte auch mit sprintf() (aus stdio.h eine formatierte Ausgabe in einen String schreiben:

sprintf(final_string, "Computername: %s", computer_name);

<FONT COLOR="#a62a2a" SIZE="1">[ 08. August 2001 15:14: Beitrag 2 mal editiert, zuletzt von Shadax ]</font>

wäre auch mit

CString String;

String = "Zeit ";

String += time;

String += " Uhr"

gergangen.

<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Zitat:</font><HR>Original erstellt von lunatic82:

<STRONG>MessageBox(NULL,"Computername:" computer_name ,"Information",MB_OK); // um die Stelle geht es eigentlich

</STRONG>

Sorry, ich nehm alles zurück was ich da gesagt hab...

Hab gerade wohl eher an VBA gedacht :)

DAs mit dem & geht wohl doch nicht :eek:

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.