(Sorry if the title does not really match the question.)
I have been hardcoding filenames into my code but have been told that that is error prone and hard to maintain.
I have tried to recode to achieve this but am getting complier errors.
As an example I have a file name declared and defined as shown below.
Code:
char index_file[10] = "index.dat"; //correctly formatted files stored in here
Further on in my code I have need to use that file name. At present I need to hard code it in e.g.
Code:
strncat(shorttiffUrl, "index.dat", 40);
Is it possible to replace the index.dat by something that points to the original declaration?
I have tried
Code:
strncat(shorttiffUrl, index_file, 40);
and
Code:
strncat(shorttiffUrl, *index_file, 40);
but both give complier errors e.g
Code:
C:/ScanImages/findRPTfiles-4.cpp: In function `int main(int, char**)':
C:/ScanImages/findRPTfiles-4.cpp:204: error: invalid conversion from `char' to `const char*'
C:/ScanImages/findRPTfiles-4.cpp:204: error: initializing argument 2 of `char* strncat(char*, const char*, size_t)'
mingw32-make.exe[1]: *** [Debug/findRPTfiles-4.o] Error 1
I am sure that the answer is staring me in the face but I cannot see it.
I know that this will be useful for later in my nascent coding career.