rendered paste body#include <stdio.h>
#include <string.h>
main() {
char s1[20];
strcpy(s1,"hallo");
char s2[20];
strcpy(s2, "fritz");
// strings zusammenfügen
strcat(s1, s2);
printf("\nThe string entered is %s", s1);
int length=strlen(s1);
printf("\nNumber of characters in the string is=%d",length);
char kommt = 'b';
// Anfang des Strings merken
//Pointer to type character
char *ps1;
ps1 = s1;
// String ausgeben
puts(ps1);
while(*ps1 != '\0')
{
*ps1++;
}
*ps1++=kommt;
*ps1='\0';
printf("\nThe string entered is %s", s1);
int x=strcmp(s1,"hallofritzb");
if(x!=0)
{
printf("\nStrings are not equal\n");
}
else {
printf("\nStrings are equal");
}
// String leeren
ps1=s1;
*ps1='\0';
printf("\nAfter leeren %s", s1);
// my_strcpy(ga1,ga2);
//char s3[20]; s3 = "Test";
// printf("S3: %s", s3);
printf("\n");
meins(s1, kommt);
}
char *my_strcpy(char *destination, char *source)
{
char *p = destination;
while (*source != '\0')
{
*p++ = *source++;
}
*p = '\0';
return destination;
}
void meins(char in[20], char zeichen) {
// Ein Char an einen Strin ganfügen}
/* char *p=in;
while (*p != '\0')
{
*p++;
}
*p=zeichen;
*p='\0'; */
}