Blah... Sorry. Hit post before I copied my code..
Here is help_fun.h
Code:
#ifndef __HELP_FUN_H
#define __HELP_FUN_H
#include <string.h> // String Functions
char * String_Concat (const char *s1, const char *s2); // Concatenates two strings and returns the result. Both s1 and s2 are unchanged.
#endif
Here is help_fun.c
Code:
#include <string.h> // String Functions
#include "help_fun.h"
/* String Concatenation Function
Version 1.0
February 10, 2009
Return Values : A pointer to a C-Style String
Parameters : Two pointers to C-Style Strings
Description : Concatenates two C-Style strings and returns the result. Both original strings are unchanged.
*/
char * String_Concat (const char *s1, const char *s2) {
char *sTemp = malloc((sizeof(char) * strlen(s1)) + (sizeof(char) * strlen(s2)));
strcpy(sTemp, s1);
strcat(sTemp, s2);
return sTemp;
}
in main.c
Code:
#include "help_fun.h" // Helper Functions
const char * const sFlash_Card_Base_Path = "C:\\TC\\HART\\Flash\\";
const char * const sDiagnostic_Log_Name = "diag_log.txt";
char *sDiagnostic_Log_Path; // Full path of diagnostic log file
int main() {
// Join sFlash_Card_Base_Path with sDiagnostic_Log_Path to give complete file location
sDiagnostic_Log_Path = String_Concat(sFlash_Card_Base_Path, sDiagnostic_Log_Name);
retun 0;
}