Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. int ReverseStrings(char buffer[])
  2. {
  3. int check = -1;
  4. int i = 0;
  5.  
  6. while (buffer[i] != '\0' && check)
  7. {
  8. if (!((buffer[i] >= 'a' && buffer[i] <= 'z') || (buffer[i] >= 'A' && buffer[i] <= 'Z') || (buffer[i] == ',')))
  9. check = 0;
  10. i++;
  11. }
  12.  
  13. if (check)
  14. {
  15. int length = i + 1;
  16. int j = i; // length of array
  17. int temp;
  18. i = 0;
  19. while (buffer[i] < length / 2 && j > length / 2)
  20. {
  21. temp = buffer[i];
  22. buffer[i] = buffer[j];
  23. buffer[j] = temp;
  24. j--;
  25. i++;
  26. }
  27. check = -1;
  28. printf("%s", buffer);
  29. }
  30.  
  31. return check;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement