Advertisement
maxim_shlyahtin

scratch

Oct 22nd, 2022 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #define N 100
  6.  
  7. struct Sentence{
  8. char* sentence;
  9. };
  10.  
  11. char* get_sent(char** string, int n){
  12. char* str = *string;
  13. int i = 0;
  14. char s;
  15. while(i < n){
  16. scanf("%c", &s);
  17. if(s == '.'|| s == '\n')
  18. break;
  19. else
  20. str[i] = s;
  21. i++;
  22. }
  23. str[i + 1] = '.';
  24. str[i + 2] = '\0';
  25. return str;
  26. }
  27.  
  28.  
  29. int main() {
  30. char* sent = malloc(N * sizeof(char));
  31. get_sent(&sent, N);
  32. struct Sentence my_sent = {sent};
  33. for(int i = 0; my_sent.sentence[i]; i++)
  34. printf("%c", my_sent.sentence[i]);
  35. free(sent);
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement