I am getting errors for the below program.
#include "stdafx.h"
#include<stdio.h>
struct s
{
char *st;
struct s *sp;
};
struct s *p1,*p2;
swap(p1,p2);
int main()
{
int i;
struct s *p[3];
static struct s a[]={
{"abc",a+1},{"def",a+2},{"ghi",a}
};
for(i=0;i<3;i++)
{
p[i]=a[i].sp;
}
swap(*p,a);
printf("%s %s %s\n",p[0]->st,(*p)->st,(*p)->sp->st);
return 0;
}
swap(p1,p2)
{
char *temp;
temp = p1->st;
p1->st = p2->st;
p2->st = temp;
}
How to make this program working.Even if we didnt put int before swap I hope it will by default take it as int .
error C4430: missing type specifier – int assumed. Note: C++ does not
support default-interror C2078: too many initializers
error C2440: ‘initializing’ : cannot convert from ‘s *’ to ‘int’
There is no context in which this conversion is possibleerror C2450: term does not evaluate to a function taking 2 arguments
error C2456:’swap’ : function-style
Try