포인터 변수는 그 값이 메모리의 번지입니다.
어떤 변수의 번지를 구하는 연산자는 &입니다.
포인터가 가리키는 번지에 있는 값을 구하는 연산자는 *입니다.
int i, j, *pi;
pi = &i;
j=*pi;
j = *&i; //j=i;
뭘 하시려는 건지는 잘 모르겠지만 아래와 같은 형식으로 해야 컴파일 에러를 피할 수 있습니다.
#include<stdio.h>
#define stop '\n'
void ex(int* pb, int* pc);
int main(void)
{
int i,a,b,c;
scanf("%d",&a);
for(i=1; i<=a; i++)
{
scanf("%d %d",&b,&c);
}
ex(&b,&c);
printf("%d %d",b,c);
return 0;
}
void ex(int *pb, int *pc)
{
int temp;
temp = *pb;
*pb += temp;
temp = *pc;
*pc += temp;
}
궁금해여~~~~~~ 님이 쓰신 글 :
: 두개값의 입력b와 c를 몇번받을지 a에 넣고 부호를 받은뒤 입력받은 b값들합과c값들합
: 두개를 출력하려는데여...
: call by reference 방식으로 두개의 값을 포인터로 함수를 만들어서 주함수에
: 수행을 할려는데여 자꾸에러가 나여...소스보시고 눈에 띄는 에러체크좀...
:
:
:
: C:\My Documents\새 폴더\Cpp1.cpp(32) : error C2660: 'ex' : function does not take 2 parameters
: C:\My Documents\새 폴더\Cpp1.cpp(34) : warning C4508: 'main' : function should return a value; 'void' return type assumed
: C:\My Documents\새 폴더\Cpp1.cpp(35) : error C2065: 'pb' : undeclared identifier
: C:\My Documents\새 폴더\Cpp1.cpp(35) : error C2065: 'pc' : undeclared identifier
: C:\My Documents\새 폴더\Cpp1.cpp(36) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
: C:\My Documents\새 폴더\Cpp1.cpp(36) : fatal error C1004: unexpected end of file found
: Error executing cl.exe.
:
: Cpp1.exe - 5 error(s), 1 warning(s)
:
: 이렇게 오류가 떠여 ....
:
:
: #include<stdio.h>
: #define stop '\n'
: main()
: {
: void ex();
: int i,a,b,c;
: scanf("%d",a);
: for(i=1; i<=a; i++)
: {
: scanf("%d %d",b,c);
: }
: ex(b,c);
: printf("%d %d",b,c);
: }
:
:
:
: void ex(pb,pc)
: int *pb,*pc;
: {
: int temp;
: temp = *pb;
: *pb += temp;
: temp = *pc;
: *pc += temp;
: }
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
|