In this Tutorial tutorial4.cpp we Teach IN manual after a Teach IN telegram, and Teach Out if we receive a second one. 
 #define SER_PORT "/dev/USB300"
#define SAVE_CONFIG "./learned.txt" 
#define LEARN_TIME_S 1 
#include <stdio.h>
int main(int argc, const char* argv[]) {
 uint16_t recv=0;
 printf("Opening Connection to USB300 \n");
 if (myGateway.
Open(SER_PORT)!=OK)
  {
  printf("Failed to open USB300\n");
  return 0;
 }
 while (1)
 {
  
  {
  }
  else if (recv & RECV_TEACHIN)
  {
  }
 }
 return 0;
}