Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct foo {
- int num;
- char *word;
- struct foo *ptr;
- };
- void func2(struct foo*);
- void func3(struct foo);
- int main() {
- a.num = 100;
- a.word = “secondword”;
- func2(&a);
- printf(“2 %d %sn”, a.num, a.word);
- a.ptr = &a;
- a.num = 50;
- a.word = “mylastword”;
- func3(&a);
- printf(“4 %d %sn”, a.num, a.word);
- }
- void func2(struct foo *a)
- {
- while(*(a->word) != ‘ ’)
- {
- putchar(*(a->word));
- a->word++;
- }
- putchar(‘n’);
- if(a->num % 10 != 0)
- { a->num *= 2; }
- a->word--;
- printf(“num is %dn”, (*a) . num);
- }
- void func3(struct foo *a)
- {
- if( (*a) . num == a->ptr->num)
- { (*a) . num = (*((*a).ptr)) . num + 1; }
- else { a->num = 200; }
- a->word = “wordsix”;
- a->ptr->word = “wordseven”;
- printf( “7th is %d %sn”, (*a) . num, (*((*a) . ptr)) . word );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement