# Revision history [back]

### reading a file and publishing data to topic

data is the file is of type int [ ] = {1,2,3,4,5,6,7,8,9,10}

Code for Node_1 is as follows:

#include<std_msgs/Int32MultiArray.h>
...
int main(int argc, char **argv)
{
int temp;

ros::init(argc, argv, "Node_1");

ros::NodeHandle nh;

std_msgs::Int32MultiArray vec;

ifstream infile("array1.txt");

while(infile >> temp)
{
ROS_INFO("Extracting the elements of the vector from file");
vec.data.push_back(temp);
}
publisher.publish(vec);
ros::spinOnce();

return 0;
}


Executables are created when I compile (using catkin_make)

But when I run this node, the statement

"ROS_INFO("Extracting the elements of the vector from file");"


is not at all executed

What could probably be going wrong?

### reading a file and publishing data to topic

data is in the file is of type int [ ] = {1,2,3,4,5,6,7,8,9,10}

Code for Node_1 is as follows:

#include<std_msgs/Int32MultiArray.h>
...
int main(int argc, char **argv)
{
int temp;

ros::init(argc, argv, "Node_1");

ros::NodeHandle nh;

std_msgs::Int32MultiArray vec;

ifstream infile("array1.txt");

while(infile >> temp)
{
ROS_INFO("Extracting the elements of the vector from file");
vec.data.push_back(temp);
}
publisher.publish(vec);
ros::spinOnce();

return 0;
}


Executables are created when I compile (using catkin_make)

But when I run this node, the statement

"ROS_INFO("Extracting the elements of the vector from file");"


is not at all executed

What could probably be going wrong?