ruby 練習

(s1)

def ask
  puts '調べたいIP(0.0.0.0)'
  gets.chomp
end

while ipAdd=ask
  system("nslookup "+ipAdd)
end

似たものをc++

#include 
#include 

char *ask()
{
  static char ans[100]; 
  strcpy(ans,"");
  cout<<"調べたいIP(0.0.0.0)";
  cin>>ans;
  return ans;
}

int main()
{
  while (1)
  {
    char *ipAdd =ask();
    if(strlen(ipAdd)<2) break;
    char co[200];
    sprintf(co,"nslookup %s", ipAdd);
    system(co);
  }
}