Solved

Function header ?

Posted on 2006-11-18
6
207 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

Question has a verified solution.

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

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…
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…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them 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.

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now