Compro2 String Removing and String Functions
Compro2 String Removing and String Functions
1. #include <stdio.h>
2. #include <string.h>
3. int main()
4. {
5. int i,n,p,k;
6. char a[100];
7.
8. printf("Enter the String without space: ");
9. scanf("%s", a);
10. printf("Enter position: ");
11. scanf("%d",&p);
12.
13. printf("\nEnter number of characters: ");
14. scanf("%d",&n);
15. k=p+n-1;
16. i=0;
17. for (i=p-1; i<strlen(a)-n;i++){
18. a[i]=a[k++];
19. }
20. a[i]='\0';
21. printf("string after removing character/characters: %s ",a);
22.
23.
24. return 0;
25.}
#include<stdio.h>
#include<string.h>
int main(){
char nama[20];
char temp[20];
printf("masukkan nama kata/kalimat: ");
gets(nama);
printf("hasil copy: %s\n",strcpy(temp,nama));
if (strcmp(temp,nama)==0){
printf("\n%s adalah palindrom\n",nama);
printf("\ncoba gabung: %s\n", strcat(temp,nama));
}
else printf("%s bukanlah palindrom",nama);
return 0;
}