#include<stdio.h>
void swap(int p1, intp2)
{
int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}
void main
{
int a, b;
int *pp1, int *pp2;
pp1=&a;
pp2=&b;
scanf("%d%d",&a,&b);
if(a<b)
swap(pp1,pp2);
printf("a=%d,b=%d\n",a,b);
}
void main()
建议将报错内容一并发出来。
你的main函数不对,int *pp1后面应该是分号
修改如下,供对照参考:
#include<stdio.h>
void swap(int *p1, int *p2) //void swap(int p1, int p2)
{
int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}
void main()//void main
{
int a, b;
int *pp1,*pp2;//int *pp1, int *pp2;
pp1=&a;
pp2=&b;
scanf("%d%d",&a,&b);
if(a<b)
swap(pp1,pp2);
printf("a=%d,b=%d\n",a,b);
}
报错内容
Compile error: /storage/emulated/0/Android/data/com.cjkj.clanide/files/CJ_IDE/CProject/sy.cpp/src/hf.c:10:1: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
{
^