?
Solved

Function header ?

Posted on 2006-11-18
6
Medium Priority
?
215 Views
Last Modified: 2010-05-18
#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. ?

0
Comment
Question by:thefirstfbli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 15

Accepted Solution

by:
mish33 earned 1200 total points
ID: 17973115
void funca (A *a);
double funcb (A *a);
0
 
LVL 1

Author Comment

by:thefirstfbli
ID: 17974002
still gives segmentation fault.. when // this lines it works so i think error is caused by these lines.
0
 
LVL 15

Expert Comment

by:mish33
ID: 17974031
You better initialize p1 and p2, also funca returns void so assign it to one is useless.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:numansiddique
ID: 17975145
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
 
LVL 8

Assisted Solution

by:deepu chandran
deepu chandran earned 120 total points
ID: 17977753
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
 
LVL 53

Expert Comment

by:Infinity08
ID: 17985916
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question