Function header ?

#include "stdio.h"
...

typedef struct  {
      
}A;

double funcb( what is this ? ); // this line ?
void funca ( what is this ? );  // this line ?

main()
{
.. ..



A *p1;
A *p2;

one=funca(p1);
two=funcb(p2);

printf("two is : %f" two);

return 0;
}


void funca (A *a)  {
}

double funcb (A *a) {
}


my program is not all but the problem is caused by header of the function. how can i fix. ?

LVL 1
thefirstfbliAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mish33Connect With a Mentor Commented:
void funca (A *a);
double funcb (A *a);
0
 
thefirstfbliAuthor Commented:
still gives segmentation fault.. when // this lines it works so i think error is caused by these lines.
0
 
mish33Commented:
You better initialize p1 and p2, also funca returns void so assign it to one is useless.
0
Choose an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

 
numansiddiqueCommented:
You have declared
A *p1;
A *p2;

but you have never allocated memory for this.
you have to do
p1 = (A *)malloc(sizeof(A));
p2 = (A *)malloc(sizeof(A));

you are getting segmentation fault because you are using p1 and p2 without allocating memory for it.
hope this would help you

regards
Numan
0
 
deepu chandranConnect With a Mentor Commented:
Hi,

In the initialization part you have initialize the funca as
>>[void funca ( what is this ? );]    

In calling part you are tring to call like this  >>  one=funca(p1);  I think this could be the Error
you are tring to get the value from a non returnable function

try to call the function like this >>funca(p1);  or change the return type in the prototype

cheers
Deepu
0
 
Infinity08Commented:
And if these comments still don't solve your problem, can you post a bit more code (preferrably all if it's not too big), and the exact error you get ?
0
All Courses

From novice to tech pro — start learning today.