I have an assignment where I need to make a utility where if ran, it would perform the same action as a tee command in linux.

So the tee command takes the command line:

ls *.txt | tee txtfiles.txt

But for my assignment if I named the utility to be "test" then the command line would run:

ls *.txt | test txtfiles.txt

I am making this utility in C++ and need to use GNU Tools (so autoconf, automake, ./configure, etc) to compile the utility. I have no clue how to code the tee command in c++ as my background is VERY MINIMAL. One friend suggested I try this code:

#include <fstream>

      int main( int argc, const char** argv )
      {
      std::ofstream file(argv[1]);
      teestream teeout(std::cout, file);
      teeout << std::cin.rdbuf();
      }

I tried running ./configure and then make but a number of errors pop up when I run make:

gcc -DPACKAGE=\"test\" -DVERSION=\"1.0\"  -I. -I.      -g -O2 -c test.c
test.c:1:19: error: fstream: No such file or directory
test.c: In function ‘main’:
test.c:5: error: expected expression before ‘:’ token
test.c:6: error: ‘teestream’ undeclared (first use in this function)
test.c:6: error: (Each undeclared identifier is reported only once
test.c:6: error: for each function it appears in.)
test.c:6: error: expected ‘;’ before ‘teeout’
test.c:7: error: ‘teeout’ undeclared (first use in this function)
test.c:7: error: ‘std’ undeclared (first use in this function)
test.c:7: error: expected ‘;’ before ‘:’ token
make: *** [test.o] Error 1

Help? :(

This is the important line:

test.c:1:19: error: fstream: No such file or directory

It means your system is not setup correctly. I would try

sudo yum install glibc* gcc* libc*

and then see how it goes.

David

What about the other errors?

I don't use linux, but just as a general debugging guideline you should always address the first error first. It is likely that the first error is the root/cause of others in the list. If you fix it successfully, it may eliminate most (if not all) of the others for you.

Okay, well it looks like glibc was not installed so it's unpacking right now :)
We'll see how it goes!

Same errors...

Are you sure there is no problem with your code?
What do you want to do?

Try installing the libstdc++* packages.