Difference between char *str1 & const char *str2
Gudday all
On a previous thread http://cboard.cprogramming.com/c-pro...rs-string.html I was given some help to extract and correctly terminate strings.
My next step is to concatenate two strings, comprising a path and a file name, and then move the file to the new location using rename() and so move the file to its new location.
I thought that I would make a new variable to hold the concatenated strings (path and file) and then put that new variable into rename().
Code:
#include <cstring.h>
const size_t size = 64;
...
char move_tiff_file[size+1] = {0}; //final destination of TIFF file /* this var. added 05/08 */
...
/* these next 2 lines added 05/08 */
move_tiff_file = strncat(dest, tiff_file, size);
rename(tiff_file, move_tiff_file);
When I build the code I get the error message in the strncat line " error: incompatible types in assignment of `char*' to `char[65]' ".
Looking at a reference site for C and looking up strncat I see the following
Quote:
#include <cstring>
char *strncat( char *str1, const char *str2, size_t count );
dest and tiff_file are both char*
Q: What is the difference between char *str1 & const char *str2?
Q: What is wrong with either my definition of move_tiff_file or my handling of strncat?