how about making/putting functions in a header file and calling that in another program
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14
Hmmm... sounds good! How do we do that????? how to make our own header???
Have you searched the web for examples?
N i guess there is a way to call a program in some other program! thats why we use int main() right???
Now this is different than just using simple header files
Here's a link that should help you get started
http://www.gidforums.com/t-3369.html
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14
This is where you start to learn how to write functions, use standard functions, and build related ones into libraries. Example, using your code to build on. Note that the function str2int(const char* numString) can be built into a library that you can link to any program you write, and then call from any related code.
#include <conio.h>
#include <stdio.h>
#include <ctype.h>
int str2int( const char* numString )
{
int results = -1; // Default means not a number.
if ((numString != NULL) || isdigit(*numString))
{
results = atoi(numString);
}
return results;
}
int main()
{
char *buffer = 0;
size_t numRead = 0;
printf("Enter a number: ");
fflush(stdout);
buffer = getline(0, &numRead, stdin);
if (buffer != 0)
{
printf("%d\n", str2int(buffer));
free(buffer);
}
return 0;
}
rubberman
Posting Maven
2,578 posts since Mar 2010
Reputation Points: 365
Solved Threads: 307
Skill Endorsements: 52
there are following comments on that link that tells on how to do it on windows, using the Windows API, etc.
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14