473,412 Members | 4,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

header file creating in c language

first i create a header file name is sample.h
and write with in it
Expand|Select|Wrap|Line Numbers
  1. int sum(int x,int y);
  2. float average(float x,float y,float z);
  3.  
.................................................. ......
after that i create a file name is sample.c
in which i write..
Expand|Select|Wrap|Line Numbers
  1. int sum(int x,int y)
  2. {
  3. return(x+y);
  4. }
  5. float average(float x,float y,float z)
  6. {
  7. return((x+y+z)/3);
  8. }
  9.  
................................................
after that i write a file name is example.c
in which i write
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include"sample.h"
  3. main(){
  4. int thesum=sum(10,10);
  5. float theaverage=average(2.3,5.7,88,5);
  6. printf("%i",thesum);
  7. printf("%f",theaverage);
  8. getch();
  9. return 0;
  10. }
  11.  
?///////////////////////////////////////
but after complitation.......
error message are>>>>>>>>
undefined symbol sum in module sample.c
undefined symbol average in module sample.c
..................................
plz help me
Aug 20 '07 #1
2 4283
Banfa
9,065 Expert Mod 8TB
Have you included sample.h in sample.c
Aug 20 '07 #2
kreagan
153 100+
Though I don't think this will solve your problem, line 5 in example.c has too many parameters.

You have

Expand|Select|Wrap|Line Numbers
  1. float theaverage=average(2.3,5.7,88,5);  //Four parameters
It should be

Expand|Select|Wrap|Line Numbers
  1. float theaverage = average(2.3,5.7,88.5) //three parameters
I don't see anything else wrong syntax wise. You might want to make sure the sample.h file is in your class path. Example.c might not "see" sample.h. Are all these files in the same folder? What IDE (if you are using any) are you using?
Aug 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: alan | last post by:
Dear all, I have written my own function by C. And my development platform is W2k with VC6.0. Then I also defined a header file to extern declare this function. After that, I include this...
4
by: s.subbarayan | last post by:
Dear all, How different is a header file from a library file in C?Under what circumstance u go for library and under what circumstance u go for header?Afaik,both have some declarations which can...
6
by: candy | last post by:
hi all, I just want to know that whether the C header files( like stdio.h,etc which the compiler provides) just contains the function declarations or they also contain some additionalinformation...
7
by: paytam | last post by:
How can I define my own header file?(I use linux,but when I use sine or cosine and etc. I faced to error,so I read the header file but there wasn't any prototype of that functions,so I decided to...
4
by: Adam Clauss | last post by:
OK, lets say I have a C# Windows application. In it is a a series of namespaces, all rooted for a certain namespace A. For ex, the "using" directives would read something like: using A; using...
2
by: Annie | last post by:
hello guys, I have a header file in the form of user control (.ascx) that all my pages inherit from it. I have a textbox that i need to access it from all the pages actually i show there user...
18
by: Al | last post by:
I'm still trying to do this but it never worked! In a .cpp file, I write the code, and at the beginning, I write: #ifndef MYLIST_H #define MYLIST_H ....to end: #endif What's wrong with it for...
3
by: andrejohn.mas | last post by:
Hi, I am writing a C++ program that needs to include a C header file. The problem I am having is that a couple of the functions have 'new' as parameter name: int kernel_sysctl(struct proc *p,...
11
by: whirlwindkevin | last post by:
I saw a program source code in which a variable is defined in a header file and that header file is included in 2 different C files.When i compile and link the files no error is being thrown.How is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.