C++ Vex v5 cannot use function

#include "vex.h"

using namespace vex;

int write(char text) {
  Brain.Screen.print(text);
  Brain.Screen.newLine();
  return 0;
}

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();
  Drivetrain.setDriveVelocity(100, percent);
  //Drivetrain.drive(forward);
  int creller = write("Test");
}

This gets me the error by write:
No matching function to call ‘write’

How can I fix this?

Your function write takes a char which is a single character:

https://www.learncpp.com/cpp-tutorial/chars/

You probably want write to take an std::string instead:

https://www.cplusplus.com/reference/string/string/

3 Likes

You need to define write as:

int write(const char* pText)
{
   Brain.Screen.print(pText);
   Brain.Screen.newLine();
   return 0;
}

because compiler sees “Test” as const char*

Then everything should work.

1 Like

I’m assuming that you meant “text”