Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cstdlib>
  3.  
  4. void posun_tablice(char *tekst, int start, int offset)
  5. {
  6. char tab[100];
  7. int counter = 0;
  8. int counter_2 = start;
  9. while (tekst[counter_2]!='\0')
  10. {
  11. tab[counter] = tekst[counter_2];
  12. counter_2++;
  13. counter++;
  14. }
  15. tab[counter + 1] = '\0';
  16. int replace_offset = start + offset;
  17. counter = 0;
  18. while (tab[counter]!='\0')
  19. {
  20. tekst[replace_offset] = tab[counter];
  21. counter++;
  22. replace_offset++;
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. }
  32. int main()
  33. {
  34. char f[100] ="Normalnynapis";
  35. posun_tablice(f, 4, 5);
  36. printf("%s", f, sizeof(f));
  37. //char t[100];
  38. //char f[100];
  39. //char r[100];
  40.  
  41.  
  42.  
  43.  
  44.  
  45. //char c_to_search[5] = "asdf";
  46.  
  47. //char text[68] = "hello my name is \0 there is some other string behind it \n\0 asdf";
  48.  
  49. //int pos_search = 0;
  50. //int pos_text = 0;
  51. //int len_search = 4;
  52. //int len_text = 67;
  53. //for (pos_text = 0; pos_text < len_text - len_search; ++pos_text)
  54. //{
  55. // if (text[pos_text] == c_to_search[pos_search])
  56. // {
  57. // ++pos_search;
  58. // if (pos_search == len_search)
  59. // {
  60. // // match
  61. // printf("match from %d to %d\n", pos_text - len_search, pos_text);
  62. // system("pause");
  63. // return 1;
  64. // }
  65. // }
  66. // else
  67. // {
  68. // pos_text -= pos_search;
  69. // pos_search = 0;
  70. // }
  71. //}
  72. //// no match
  73. //printf("no match\n");
  74.  
  75.  
  76.  
  77.  
  78. system("pause");
  79.  
  80.  
  81.  
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement