How to combine variables into a string??

Alright so, I’m trying to write this program, and I have this function that prints a string to a modem and I want to transmit latitude and longitude to it. The problem is that those are defined as different variables in the code and I need to make them as one message. I don’t really know how to do this because

char message = longitude + ", " latitude

Doesn’t work
Also, I tried

std::string

And included

#include <string>

But that came up with the error “‘string’ is not a member of ‘std’”
This is my whole code:

//------------{Libraries}----------//
#include <Wire.h> //Needed for I2C to GPS
#include <IridiumSBD.h>
#include <string>
#define IridiumSerial Serial3
#define DIAGNOSTICS false // Change this to see diagnostics
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
//--------------------------------//

SFE_UBLOX_GPS myGPS;
IridiumSBD modem(IridiumSerial);

long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.

void setup() {
  int signalQuality = -1;
  int err;
  Serial.begin(115200);
  Wire.begin();
  while (!Serial);
  IridiumSerial.begin(19200);
  Serial.println("Starting modem...");
  err = modem.begin();
  if (err != ISBD_SUCCESS) {
    Serial.print("Begin failed: error ");
    Serial.println(err);
    if (err == ISBD_NO_MODEM_DETECTED) {
      Serial.println("No modem detected: check wiring.");
    } return;
  }

  
  if (myGPS.begin() == false) {
    Serial.println(F("Ublox GPS not detected, Is it plugged in?"));
    while (1);
  }

  myGPS.setI2COutput(COM_TYPE_UBX);
  myGPS.saveConfiguration();

  char version[12];
  err = modem.getFirmwareVersion(version, sizeof(version));
  if (err != ISBD_SUCCESS) {
     Serial.print("FirmwareVersion failed: error ");
     Serial.println(err);
     return;
  }
  Serial.print("Firmware Version is ");
  Serial.print(version);
  Serial.println(".");

  err = modem.getSignalQuality(signalQuality);
  if (err != ISBD_SUCCESS) {
    Serial.print("SignalQuality failed: error ");
    Serial.println(err);
    return;
  }

  Serial.print("On a scale of 0 to 5, signal quality is currently ");
  Serial.print(signalQuality);
  Serial.println(".");

  long latitude = myGPS.getLatitude();
  long longitude = myGPS.getLongitude();

  if(latitude and longitude == 0) {
    Serial.println("Error: Could not get GPS coordinates");
    while (1);
  } else {
    char message = latitude + ", " + longitude;
    Serial.print("Trying to send the message.  This might take several minutes.\r\n");
    err = modem.sendSBDText(message);
    if (err != ISBD_SUCCESS) {
      Serial.print("sendSBDText failed: error ");
      Serial.println(err);
      if (err == ISBD_SENDRECEIVE_TIMEOUT) {
      Serial.println("Try again with a better view of the sky.");
      }
    } else {
      Serial.println("Hey, it worked!");
    }
  }
}

void loop() {
}

#if DIAGNOSTICS
void ISBDConsoleCallback(IridiumSBD *device, char c) {
  Serial.write(c);
}

void ISBDDiagsCallback(IridiumSBD *device, char c) {
  Serial.write(c);
}
#endif

Does it matter to the modem that they’re combined?

Yes, If the messages weren't combined then it would send them as separate messages and use more credits.

Stockbridge_InvenTeam:
Yes, If the messages weren't combined then it would send them as separate messages and use more credits.

I can't see how the modem could tell the difference between

Serial.print("hello world");

and

Serial.print("hello");
Serial.print(" world");

...R

Sorry, the modem sends messages through

modem.sendSBDText("Test");

not Serial.print

What is the “modem” object?
Does it inherit from “Stream”?

If not, why not?

"modem" is from

IridiumSBD modem(IridiumSerial);

which is from

#define IridiumSerial Serial3

I updated my original post with the code in it. I'm kinda dumb cause I haven't done a lot with C++

No, you’re kinda dumb because you didn’t post any of that stuff at the beginning.

Now I’ve got to go away and find that library.

Meanwhile, what about strncpy and strncat?

you need to use the sprintf() function [or snprintf()]

//------------{Libraries}----------//
#include <Wire.h> //Needed for I2C to GPS
#include <IridiumSBD.h>
#define IridiumSerial Serial3
#define DIAGNOSTICS false // Change this to see diagnostics
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
//--------------------------------//

SFE_UBLOX_GPS myGPS;
IridiumSBD modem(IridiumSerial);

long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.

void setup() {
  int signalQuality = -1;
  int err;
  Serial.begin(115200);
  Wire.begin();
  while (!Serial);
  IridiumSerial.begin(19200);
  Serial.println("Starting modem...");
  err = modem.begin();
  if (err != ISBD_SUCCESS) {
    Serial.print("Begin failed: error ");
    Serial.println(err);
    if (err == ISBD_NO_MODEM_DETECTED) {
      Serial.println("No modem detected: check wiring.");
    }
    while (1);
  }

  if (myGPS.begin() == false) {
    Serial.println(F("Ublox GPS not detected, Is it plugged in?"));
    while (1);
  }

  myGPS.setI2COutput(COM_TYPE_UBX);
  myGPS.saveConfiguration();

  char version[12];
  err = modem.getFirmwareVersion(version, sizeof(version));
  if (err != ISBD_SUCCESS) {
    Serial.print("FirmwareVersion failed: error ");
    Serial.println(err);
    while(1);
  }
  Serial.print("Firmware Version is ");
  Serial.print(version);
  Serial.println(".");

  err = modem.getSignalQuality(signalQuality);
  if (err != ISBD_SUCCESS) {
    Serial.print("SignalQuality failed: error ");
    Serial.println(err);
    while(1);
  }

  Serial.print("On a scale of 0 to 5, signal quality is currently ");
  Serial.print(signalQuality);
  Serial.println(".");

  long latitude = myGPS.getLatitude();
  long longitude = myGPS.getLongitude();

  if (latitude == 0 && longitude == 0) {
    Serial.println("Error: Could not get GPS coordinates");
    while (1);
  } else {
    char message[50];
    sprintf(message, "%ld, %ld",latitude,longitude);
    Serial.print("Trying to send the message.  This might take several minutes.\r\n");
    err = modem.sendSBDText(message);
    if (err != ISBD_SUCCESS) {
      Serial.print("sendSBDText failed: error ");
      Serial.println(err);
      if (err == ISBD_SENDRECEIVE_TIMEOUT) {
        Serial.println("Try again with a better view of the sky.");
      }
    } else {
      Serial.println("Hey, it worked!");
    }
  }
}

void loop() {
}

#if DIAGNOSTICS
void ISBDConsoleCallback(IridiumSBD *device, char c) {
  Serial.write(c);
}

void ISBDDiagsCallback(IridiumSBD *device, char c) {
  Serial.write(c);
}
#endif

sprintf is a bit of a fly-swatting bazooka - if you find yourself short on memory, itoa, ltoa and dtostrf (who makes up these names?) are the ones to look at, along with strncpy etc.