I wrote the following:
#include <stdlib.h>
#include <stdio.h>
void ExecAsRoot (char* str);
int main ()
{
  printf ("Host real ip is:");
  ExecAsRoot("ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1  -d'/'");
  return 0;
 }
void ExecAsRoot (char* str) {
  system (str);
}
My expected output is:
Host real ip is:7.17.11.29
While the actual output is:
7.17.11.29
Host real ip is:
Why is this?