Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A more general solution is to use the snprintf() function:, which also truncates name if it will not fit in the filename.

Code Block
bgColor#ccccff
langc
#include <stdio.h>
 
void func(const char *name) {
  char filename[128];
  snprintf(filename, sizeof(filename), "%s.txt", name);
}

...