5GB).
Ground21 =D0=C9=D3=C1=CC(=C1):
Hello.
How could Ireadthe whole textfileline after line from the end of
file? (I want to ~copy~file)
Take it, i am slightly adapted it for C++ from C:
Declare in your program:
#include <stdio.h>
namespace NGround21
{
typedef unsigned int uint;
// store 'max_visible_chars' chars maximum to 'buf' and close by \0
//( ! ADD '\0' char to buf, total size can be 'max_visible_chars' +1
maximum )
// all 256 chars of DOS/Win/UNIX <EOL> allowed
//special: to skip all chars till <EOL> write:
getln(any_number,0,correct_pointer);
// "fi" must be open as "rb"
// return 0 if errors in parameters, else return !0
// "fi"filepointer will be after <EOL> if return !0
char getln(char *const buf, const uint max_visible_chars,FILE
*const fi)throw();
//namespace NGround21}
using namespace NGround21;
Write as separated cppfile, compile it and then link objectfileto
your project
#include <stdio.h>
char NGround21::getln(
char *const buf,
const uint max_visible_chars,
FILE*const fp
)throw()
{
if(
( (max_visible_chars) && (!buf) )
||( !fp )
)return 0;
char *p=buf;
for( uint len=0; ; )
{
int ch=fgetc(fp);
if( feof(fp) )break;
if( ch==13 )continue;
if( ch==10 )break;
if( len >= max_visible_chars )continue;
++len;
*p++=static_cast<char>(ch);
}
if( p ) *p=0;
return 1;
}- Hide quoted text -
- Show quoted text -