SHARE
TWEET

Untitled

a guest May 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdlib.h>
  2. char *insert(char *napis, int indeks, const char *napiss){
  3. static int uruchom=1;static int a=0;int b=0;int x=0;
  4. if (uruchom==1){
  5. for(int i=0;napiss[i]!='\0';i++){
  6. a++;
  7. }
  8. napis = (char*) malloc((a+1) * sizeof(*napis));
  9. for(int i=0;i<a;i++)
  10. {
  11. napis[i]=napiss[i];
  12. }uruchom++;
  13. return napis;
  14. }
  15. else{
  16. for(int i=0;napiss[i]!='\0';i++){
  17. b++;
  18. }
  19. napis= (char*)realloc(napis, 2*(a+b)*sizeof(*napis));
  20. for(int i=0;i<a+b;i++)
  21. if(i==indeks){
  22. for(int i=indeks;i<b;i++){napis[i+b]=napis[i];}}
  23. for(int i=0;i<b;i++){napis[indeks+i]=napiss[i];}
  24. return napis;
  25. }}
  26.  
  27. #include<stdio.h>
  28. int main() {
  29. char *string = calloc(1, 1);
  30. string = insert(string, 0, "diary");
  31. string = insert(string, 2, "ction");//dictionary
  32. printf("%s\n", string);
  33. free(string);
  34. return 0; }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top