#include #include #include /* Kleine Demo interessanter Funktionen zum Umgang mit Strings */ int main(){ char aString[] = "Hallo, Welt!"; char* anotherString; /*Strings kopieren, incl. Speicher-Allokation*/ anotherString = strdup(aString); printf("%s -> %s\n", aString, anotherString); free(anotherString); /*Strings kopieren, OHNE Speicher-Allokation*/ //anotherString = (char*)calloc(strlen(aString), sizeof(char)); strcpy(anotherString, aString); /*anotherString[strlen(aString)] = '\0';*/ printf("%s -> %s\n", aString, anotherString); /*Strings vergleichen*/ if(strcmp(aString, anotherString)==0) puts("Beide Strings sind identisch.\n"); free(anotherString); return 0; }