Microsoft Visual Studio C Runtime Library has detected a fatal error in filecopy.exe?

A1ex07 has addressed some of the issues with your current code. However, as I stated in comments, I think your code could be implemented more effectively with some more significant changes.

A1ex07 has addressed some of the issues with your current code. However, as I stated in comments, I think your code could be implemented more effectively with some more significant changes. I believe you have the following problems: You are allocating a buffer on the heap and failing to free it.

Your buffer is rather small. It would likely be more efficient to use a larger buffer. The use of fgets and strlen, C string oriented functions is inappropriate for what is a byte-by-byte copy operation.

I would write it like this: void CopyTo(FILE *x) { FILE *f0; char buff16*1024;//16kB buffer, stack allocated size_t count; f0=fopen("file0. Txt", "wt+"); do { count = fread(&buff, 1, sizeof(buff), x); if (!ferror(x)) { fwrite(&buff, 1, count, f0); } } while (count == sizeof(buff)); fclose(f0); }; Note that this function has no error checking. Neither did yours.

I'll leave it to you to add that if you wish. Also, I've only compiled this in my head. If there are any glitches I'm sure you can sort them out.

And it still breaks. But it works normal on another compiler. Sth with visual studio.

Try to reinstall – Нртём Царионов Nov 14 at 20:40 I think it would be better to rewrite it in c++ with fstream and etc. – Нртём Царионов Nov 14 at 22:50 That would make life easier. Then you'd get error handling through exceptions. – David Heffernan Nov 14 at 22:50 Hm...Either to read atricles about streams in C++(I don't know how to work with files in C++.

I know only how to work with it in C#) or just write whole program in another compiler. – Нртём Царионов Nov 14 at 23:15 Well, I can't see what's wrong with the MS compiler. Really should work fine.

– David Heffernan Nov 14 at 23:17.

It looks like you are trying to read from and write to the same file (x). Shouldn't it be fwrite(s,1,strlen(s),f0)? UPDATE Also , I believe it should be while(fgets(s,100,x)), because sizeof(s) returns size of (char*).

1 strlen(s)+1 is wrong I think. No need for the +1. – David Heffernan Nov 14 at 19:48 However it doesn't solve the problem.It fails on while(fgets...)) – Ð?

ртём Царионов Nov 14 at 20:03 @David Heffernan : you are right. Fixing; I just copied it from the question. – a1ex07 Nov 14 at 20:07 @Ð?

ртём Царионов : Check if updated answer works for you – a1ex07 Nov 14 at 20:13 I have tried another compiler(C-free 4) and it seems to work correctly. Sth with visual studio – Ð? ртём Царионов Nov 14 at 20:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions