Yes, I guess so.
But I didn't understand the formatting of Master's example.
Sorry
The only formatting flag I had in there was a single %s. Which simply places a string. I used snprintf() so that one can avoid buffer overflow.
snprintf([string], [size of the string], [format], ...)
in trying to compile
I get error "nested functions are disabled, use -fnested-functions to re-enable"Code:size_t get_user_file_path(char *buffer, size_t size, const char *user) { return snprintf(buffer, size, "/%s/Desktop/database.txt", user); }
what does this mean?
Don't make a nested function, silly. Put it outside of main.
What is that function:
It doesn't take user input...Code:size_t get_user_file_path(char *buffer, size_t size, const char *user) { return snprintf(buffer, size, "/%s/Desktop/database.txt", user); }
It is assumed, by this function, that you have already gotten the input and it will be passed in as the third parameter.
So why call it?
Sorry, I just caught onto what that element is for...
I was assuming I would supply my own string getting function, but then you handed me the above code, with which I was unfamiliar, and I thought this was a better way to get it...
But now I understand what it does...
Thanks for your help
If my example is not suitable for exactly what you are doing be less general and tell me exactly what it is you want.
The only different way of doing this would be:
Example:
But that is more lines of code... *shrug*Code:char buffer[MAX_PATH] = "/" strncat(buffer, user, MAX_PATH); strncat(buffer, "/Desktop/database.txt", MAX_PATH);