Solved

Function header ?

Posted on 2006-11-18
6
208 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

773 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