Theres a problem sending a file to a function in console applications for me; you may help me! I have included <fstream.h> and <iostream.h> and declared a variable by ifstream file. Now theres a function whose prototype reads as follows:
void countfile (, ifstream &file,);
This functions tries to read all the characters of file and performs some task. The effect of calling countfile(, file,) is that cout (or anything like it, such as printf) doesnt work!
Thanks for reply
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Theres a problem sending a file to a function in console applications for me; you may help me! I have included <fstream.h> and <iostream.h> and declared a variable by ifstream file. Now theres a function whose prototype reads as follows:
void countfile (, ifstream &file,);
This functions tries to read all the characters of file and performs some task. The effect of calling countfile(, file,) is that cout (or anything like it, such as printf) doesnt work!
Thanks for reply
Hi there,
This may be of some use to you. =)
Kip
/*
Name: getFileSize()
Author: Kip Warner
Description: Returns the file size of pszFileName in bytes. -1 on error...
*/
int getFileSize(char *pszFileName)
{
// Variables...
int nFileSize = 0;
FILE *someFile;
// Open the file...
someFile = fopen(pszFileName, "r");
// Check for error...
if(!someFile)
return -1;
// Get file size...
fseek(someFile, 0, SEEK_END);
nFileSize = ftell(someFile);
// Close stream...
fclose(someFile);
// Return file size...
return nFileSize;
}