Hello ladies and gents,

I wanted to ask if any of you could help me out here, Ive got this program:

//Test programma voor Accelerated C++.

#include <fstream>
#include <iostream>
#include <string>

int main(int argc, char** argv)
	int fail_count = 0;
	//for each file in the input list
	for (int i = 1; i < argc; ++i)
		std::ifstream in(argv[i]);

		//if it exists, write its contents, otherwise generate an error message
		if (in)
			std::string s;
			while (getline(in, s))
				std::cout << s << std::endl;
			std::cerr << "cannot open file " << argv[i] << std::endl;
	return fail_count;

The program should copy the content of any file that I give as arguments to main.

What I did is, I copied the Test.exe to my C harddrive, I then created a .txt file named Tekstfile and stored that also on my C harddrive.

I then use the cmd command and enter cd c:\
I then type Test and Tekstfile.

I thought this would make the program read what is written in Tekstfile and write this in Test, but, I'm getting the error message every time saying "cannot open file" , apparantly I'm doing something wrong :?:

Could any of you help me out, thanks.

If I understand correctly, you're doing this:

C:\>Test Tekstfile

Try this instead:

C:\>Test Tekstfile.txt

Hi Narue,

Yep, you understood it perfectly, thanks for the help ;)

This question has already been answered. Start a new discussion instead.