Write string with MPI IO in C

It seems to work as you expected - I wrote one extra character to ensure I got null termination:

#include <stdio.h>
#include <string.h>
#include <mpi.h>

int main(void)
{
  int rank;
  MPI_Status status;
  MPI_File fh;

  char *x = "1111abc\n";

  MPI_Init(NULL, NULL);

  MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  MPI_File_open(MPI_COMM_WORLD, "mpiio.dat", MPI_MODE_CREATE | MPI_MODE_WRONLY,
                MPI_INFO_NULL, &fh);

  if (rank == 0) MPI_File_write(fh, x, strlen(x)+1, MPI_CHAR, &status);
  
  MPI_File_close(&fh);

  return 0;
}

If I compile and run on my laptop:

me@laptop$ mpicc -o cstring cstring.c
me@laptop$ mpirun -n 2 ./cstring
me@laptop$ cat mpiio.dat 
1111abc