I edit the code to clarify the actual code :
#include <fstream>
#include <iostream>
#include <ros/ros.h>
#include <rosbag/bag.h>
#include <std_msgs/Int32.h>
#include <std_msgs/String.h>
#include <nav_msgs/Odometry.h>
std::ofstream runtimeFile("cmg_operations_runtime.txt" , std::ios::out);
  
 void callhandler(const nav_msgs::Odometry::ConstPtr& msg)
{
   runtimeFile.open();
if (!runtimeFile)
        {
            std::cout << "cmg_operations_runtime.txt could not be opened.";
        }
         runtimeFile << "tempVector[j]" << ";\t";
         runtimeFile.close ();
        std::cout << "Runtime data stored." << std::endl;
 
}
int main(int argc, char **argv)
{
    ros::init(argc, argv, "main");
    ros::NodeHandle nh;
    ros::Subscriber Listener = nh.subscribe<nav_msgs::Odometry>("/odom", 100, callhandler);
  
    ros::spin();
    return 0;
}
error: `‘runtimeFile’ does not name a type 9 | runtimeFile.open ("cmg_operations_runtime.txt")
The error is the same, I hope someone to help me in this issue?`
 
    