-1

I am using ubuntu 14.04. I added the following code at the top of main() in a program, but I don't get anything printed when I run it.

char const* masteruri = getenv("ROS_MASTER_URI");
if (masteruri!=NULL){
printf ("The current masteruri is: %s",masteruri);
}
char const* rosdis = getenv("ROS_DISTRO");
if (rosdis!=NULL){
printf ("\n The current rosdis is: %s",rosdis);
}

but the same code in another program gives the expected result

 The current masteruri is: http://localhost:11311
 The current rosdis is: indigo

I have included stdlib.h and I exported the variables in etc/profile.d

Sofia
  • 1
  • 1
  • 2

1 Answers1

0

I don't know why, but printf was not working for some reason, I tried DEVLOG_INFO and noticed that variables values that were exported in /etc/profile.d could be returned with getenv() by both programs.

Sofia
  • 1
  • 1
  • 2