Hi,
I already have one CPP program which invokes the C program.And the C program contains whole function definitions..!This is a working program..I have to enable the logs in both CPP as well as in the C program ..!So I am reading the enviornmental variable log path from the CPP and doing the logging in CPP program..But I have to use the logging in the C program also...So again should I read the enviornmental variable for log path?As of now I am reading it in the C program also..But I dnt think it will work..I cant pass the file pointer as an argument because I dont have permission to change these functions..!I am using the gcc compiler only..!
Can anybody help me out on this..?
Example code:
test1.cpp
---------
#include "test.h"
int main()
{
char * descr = getenv("LOG_PATH");
FILE *pFile = fopen(descr,"a");
char *name;
printf("Variable is defined %s",descr);
printf("Enter the name : ");
scanf("%s" ,name);
fprintf(pFile, "name is %s: ",name);
display(name);
}
test_fun.c
-----------
//this file contains only the function definitions..
char *descr=getenv("LOG_PATH");
FILE *pFile=fopen(descr,"a");
void display(char name)
{
fprintf(pFile,"~~~~~~name is %s~~~~~~~",name);
}
test.h
------
void display(char *name);
This is an example code only..!
Thanks in advance....!!!