I want to write to a file, that is inside a folder in the current working directory, with the file name being the number value that is passed to the function.
void record_data(number[]) { FILE *fptr; fptr = fopen("./folder/number", "w"); } I'm unable to do so in this way (it names the file as number).
How can I do this properly?
(number[])in C.void record_data(const char number[])(so you pass the number as a string), then you need to concatenate the./folder/string with the number (snprintf()into a local variable) and pass the concatenated value tofopen(). If you pass the number as anint(void record_data(int number)), then you still need to usesnprintf()to format the file name into a local variable and pass that tofopen(), but the format will be different.