mhdew

Array Concatenation

Dec 21st, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. char a[100];
  6. char b[100];
  7. int al=0, bl=0;
  8. int i, j, count=0;
  9.  
  10. scanf("%s%s", a, b);
  11.  
  12. for(i=0;a[i]!='\0';i++){
  13. al++;
  14. }
  15. for(i=0;b[i]!='\0';i++){
  16. bl++;
  17. }
  18.  
  19. a[al]=' ';
  20. for(i=al+1,j=0;i<=(al+bl),b[j]!='\0';i++,j++){
  21. a[i]=b[j];
  22. }
  23.  
  24. for(i=0;i<=(al+bl);i++){
  25. printf("a[%d]=%c\n", i,a[i]);
  26. }
  27.  
  28.  
  29. for(i=0;a[i]!='\0';i++){
  30. count++;
  31. }
  32. printf("count=%d\n", count);
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment