In this code i would like to store the values that are being outputted.

fstream filestr;
	char check[4];
	filestr.open("D:\\bio.pdf", fstream::in | fstream::binary);
	if(filestr.is_open())
	{
		int i;
		char check[4]={0};
		for(i=0;i<4;i++)
		{
			filestr.read(&magic[i],1);
			cout<<hex<<static_cast<int>(check[i])<<endl; //<-- This LINE
		}
        }

The numbers that are printed here i would like to save them for later use. Can someone help me how to get this tast done.

Recommended Answers

All 2 Replies

Just open an output stream and save them to a text file, you're already halfway there.

Can you give me a little example please. Dont have to store it in a file just need to use the value again in the same program but because the values in the array where converted to hex values i want to store those hex numbers in a next string array or int array. Can someone just give me a line of code that would do that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.