Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. struct foo {
  5. int num;
  6. char *word;
  7. struct foo *ptr;
  8. };
  9.  
  10.  
  11. void func2(struct foo*);
  12. void func3(struct foo);
  13.  
  14.  
  15. int main() {
  16. a.num = 100;
  17. a.word = “secondword”;
  18. func2(&a);
  19. printf(“2 %d %sn”, a.num, a.word);
  20.  
  21.  
  22. a.ptr = &a;
  23. a.num = 50;
  24. a.word = “mylastword”;
  25. func3(&a);
  26. printf(“4 %d %sn”, a.num, a.word);
  27. }
  28.  
  29.  
  30. void func2(struct foo *a)
  31. {
  32. while(*(a->word) != ‘’)
  33. {
  34. putchar(*(a->word));
  35. a->word++;
  36. }
  37. putchar(‘n’);
  38. if(a->num % 10 != 0)
  39. { a->num *= 2; }
  40. a->word--;
  41. printf(“num is %dn”, (*a) . num);
  42. }
  43.  
  44.  
  45. void func3(struct foo *a)
  46. {
  47. if( (*a) . num == a->ptr->num)
  48. { (*a) . num = (*((*a).ptr)) . num + 1; }
  49. else { a->num = 200; }
  50. a->word = “wordsix”;
  51. a->ptr->word = “wordseven”;
  52. printf( “7th is %d %sn”, (*a) . num, (*((*a) . ptr)) . word );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement