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.

string in einen string einfügen

Empfohlene Antworten

Veröffentlicht

Hi,

gibt es unter C eine Stringfunktion die einen string in einen anderen string einfügt?

char string1[] = hllo

char string2[] = a

schnittstelle:

void string( char string1, char string2, int pos)

beispiel:

void string( string1, string2, 2)

ergebnis = hallo

Also ich meine es gibt keine solche Funktion. Aber versuchs doch mal hiermit:

void InsertString( char string1[], char string2[], int nPos )

{

int len = strlen( string1 );

int len2 = strlen( string2 );

char buffer[255] = "";

strcpy( buffer, string1+nPos-1 );

strcpy( string1+nPos-1, string2 );

strcpy( string1+strlen(string1), buffer);

strcpy( buffer, string1);

memcpy( string1, buffer, sizeof(buffer) );

return;

}

Da gibts zwei Moeglichkeiten, entweder Du schreibst Dir selbst eine entsprechende Funktion (das Beispiel oben funktioniert nur bedingt und prueft keinerlei Randbedinungen ab) oder Du verwendest - sofern Du auf einem Linux System arbeitest - die Glib, dort gibts es die passenden Funktion:

struct GString

{

gchar *str;

gint len;

};

GString* g_string_new (const gchar *init);

GString* g_string_insert (GString *string, gint pos, const gchar *val);

Du musst dann allerdings GString in Deinem Programm verwenden bzw. bei Bedarf erzeugen.

Nic

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.