echo command using c++

19,254

Solution 1

I guess this is one where you may be able to get away with "can has codez?":

#include <iostream> 
#include <iterator>
#include <algorithm>

int main(int argc, char **argv) { 

   std::copy(argv+1, argv+argc, std::ostream_iterator<char *>(std::cout, ""));
   return 0;
}

Solution 2

You could just output the data yourself using stdio methods fopen/fputs/etc..

http://linux.die.net/man/3/fputs

Share:
19,254
user1065969
Author by

user1065969

Updated on June 16, 2022

Comments

  • user1065969
    user1065969 almost 2 years

    I want to issue the echo command inside a c++ file.

    All i need to do is

    echo "xml::/var/some.xml" >> /var/config

    In C++ file, I tried,

    system("echo" + "xml::/var/some.xml" +">> /var/config");

    But it throws invalid operands of types const char[6] and const char[46] to binary operator +.

    Need help