I can't seem to figure out how to write a non const char to a file in PROS

I’ve looked at the example code provided by the pros team and some other C++ file system tutorials.
All of them require the data to be a const char. What I want is to write a motors velocity to a file. Any ideas I’m stumped? Thanks.

This is what I have right now. I can change what is put in the file with strcpy
but it also only takes a const char.

#include <cstdio>
void opcontrol() {
  char str[128];
  FILE *fp;
  strcpy(str,"love is alweys better yoe\n");
  fp = fopen("/usd/file.txt","w");

This is a link to the pros docs I looked at.

fprintf be your friend.

fprintf(fp, “Value was %d\n”, val);

You can also use snprintf and the likes to format first, write later.
man snprintf

void opcontrol()
    FILE *fp = fopen("/usd/file.txt", "w");
    std::string str;
    str = "love is alweys better yoe\n";
    str += "testing\n";
    fprintf(fp, "%s", str.c_str());