Solved

Function header ?

Posted on 2006-11-18
6
209 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
6 Comments
 
LVL 15

Accepted Solution

by:
mish33 earned 300 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 30 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

809 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