#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#pragma warning(disable:4996)

struct node {

int b;

int c;

};

void swab_ab();

struct node swab_s(struct node a);

main()

{

struct node a;

struct node *f;

f = &a;

a.b = 3;

a.c = 4;

swab_ab(a.b, a.c);

printf("%d %d\n", a.b,a.c);

a=swab_s(a);

printf("%d %d\n", a.b, a.c);

}

void swab_ab(int a,int b)

{

int tmp;

tmp = a;

a = b;

b = tmp;

printf("%d %d\n", a, b);

}

struct node swab_s(struct node a)

{

int tmp=0;

tmp = a.b;

a.b = a.c;

a.c = tmp;


return a;

}


교수님 수업에서는 그 값 자체를 바꾸려면 포인터를 이용해서 주소로 받아야 된다 하셨는데 책에서 보니까 참조 안하고도 바꿀수 있더라고?

그래서 교수님한테 물어보니까 책에나온거는 리턴해준값으로 업데이트 해주는식으로 처리해주는거라는데 

내가만든 struct node swab_s함수가 그 업데이트 해주는것처럼 만든게 맞는건가?