juzzbott
July 30th, 2009, 02:55 AM
Hey all,
I did a quick search on the net, and couldn't really see how to do this, other than using the #define preprocessor command.
I have the following 2 files:
generate.c
#include <stdio.h>
#include <stdlib.h>
/* Create the const variables */
const int DEFAULT_P_LEN = 8;
const int DEFAULT_NUM_P = 5;
/* The Generate Password function */
void generate(int p_len, int p_strength) {
// If the length passed to the function is 0, set to the default.
if (p_len == 0) {
p_len = DEFAULT_P_LEN;
}
return;
}
generate.h
#ifndef GENERATE_H_INCLUDED
#define GENERATE_H_INCLUDED
#endif // GENERATE_H_INCLUDED
/* generate password prototype */
void generate(int p_len, int p_strength);If I try and place the 2 consts into the generate.h file
#ifndef GENERATE_H_INCLUDED
#define GENERATE_H_INCLUDED
#endif // GENERATE_H_INCLUDED
/* Create the const variables */
const int DEFAULT_P_LEN = 8;
const int DEFAULT_NUM_P = 5;
/* generate password prototype */
void generate(int p_len, int p_strength);
I get the following compiler error:
error: 'DEFAULT_P_LEN' undeclared (first use in this function).
So I can assume that the const in the header file is not being used, but I thought the #include "generate.h" file would include this?
Could I please get a little help on this please.
EDIT: --- MUST INCLUDE generate.h FOR IT TO BE INCLUDED. Silly Me
Cheers,
Justin
I did a quick search on the net, and couldn't really see how to do this, other than using the #define preprocessor command.
I have the following 2 files:
generate.c
#include <stdio.h>
#include <stdlib.h>
/* Create the const variables */
const int DEFAULT_P_LEN = 8;
const int DEFAULT_NUM_P = 5;
/* The Generate Password function */
void generate(int p_len, int p_strength) {
// If the length passed to the function is 0, set to the default.
if (p_len == 0) {
p_len = DEFAULT_P_LEN;
}
return;
}
generate.h
#ifndef GENERATE_H_INCLUDED
#define GENERATE_H_INCLUDED
#endif // GENERATE_H_INCLUDED
/* generate password prototype */
void generate(int p_len, int p_strength);If I try and place the 2 consts into the generate.h file
#ifndef GENERATE_H_INCLUDED
#define GENERATE_H_INCLUDED
#endif // GENERATE_H_INCLUDED
/* Create the const variables */
const int DEFAULT_P_LEN = 8;
const int DEFAULT_NUM_P = 5;
/* generate password prototype */
void generate(int p_len, int p_strength);
I get the following compiler error:
error: 'DEFAULT_P_LEN' undeclared (first use in this function).
So I can assume that the const in the header file is not being used, but I thought the #include "generate.h" file would include this?
Could I please get a little help on this please.
EDIT: --- MUST INCLUDE generate.h FOR IT TO BE INCLUDED. Silly Me
Cheers,
Justin