I am just learning to use functions in structures can any one please explain me the error in the following code and rectify it.
Code:
#include<stdio.h>
struct shop{
int price;
}
/* You can't declare a function as an instance of struct shop.
Any expression in C, needs to terminate with a semi-colon.
*/
struct shop funcone(void)
void functwo(struct shop var1)
int main()
{ struct shop var2;
var2=funcone()
functwo(var2);
return 0;
}
void functwo(struct shop var1)
{ printf("price=%d\n"var1.price); //missing comma afterward
}
struct shop funcone(void)
{ int p;
struct shop var3;
printf("enter the price");
scanf("%d" , &p);
var3.price=p;
return part; //part is not a declared variable
}
Errors shown
func_in_struct.c:7: error: two or more data types in declaration specifiers
func_in_struct.c: In function ‘funcone’:
func_in_struct.c:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘main’
func_in_struct.c:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
func_in_struct.c:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
func_in_struct.c:27: error: expected ‘{’ at end of input
I have tried to rectify but I find the code correct to my knowledge
please guide me
Thank You
Rake