yes, c++ compilers support C and c/c++ mixed.
Yes, you can fix it. I think you need to add a seek eof to your code so the file pointer is at the end of the file so the tell will give the correct response. But my C is getting rusty... you should be able to find this in 2 seconds online (google file size in C) if that is not the correct fix. It may also work
if you open the file wb+, which I think is the same as 'ate' in c++ and sticks the pointer at the end for appending.
I hacked out something that seems to work:
1 2 3 4 5 6 7
|
int main ()
{
//FILE* fp = fopen("x5.cpp", "rb");
FILE* fp = fopen("x5.cpp", "a");
//fseek(fp,0,SEEK_END);
cout << ftell(fp) << endl;
}
|
wb+ ate my file, lol. Don't do that one.
FILE* fp = fopen("x5.cpp", "a"); is what that should have been. If you do that, you can skip the fseek line entirely -- this is the right way to do it, but the above is left in for reference in case you need to seek later.
I highly advise you to learn the c++ code though. If you have tons of code already, fixing it may be too much work, but next time...