Hello, I happen to be a novice in the realm of C++, and I'm currently confused due to this error when trying to run my application:
"Assertion Failed. Expression 'stream != NULL' ".
I've looked it up, and nothing that comes up can answer why it gives me said error. I believe it has something to do with my code:
#include "stdafx.h"
#include <stdio.h>
#include <string>
using namespace std;
using namespace System;
int extractfiledata(const char oldf[], const char newf[])
{
char idx[256];
long size;
FILE * tmpf, * updf;
fopen_s(&tmpf, oldf, "w");
fopen_s(&updf, newf, "r");
size = ftell(updf);
if(tmpf != NULL && updf != NULL)
{
while(fread(idx, 1, size, updf))
{
string tmpstr(idx);
int pos=0;
int chk=0;
do
{
if(sizeof(updf) >= 256 && pos >= 256)
{
tmpstr.clear();
pos=0;
continue;
}
if(chk == sizeof(updf))
{
chk=0;
pos=0;
break;
}
fwrite(&idx[pos], 1, sizeof(&idx[pos]), tmpf);
pos++;
chk++;
}
while(pos<256);
}
fclose(updf);
fclose(tmpf);
}
return 0;
}
int main(array<System::String ^> ^args)
{
char oldfile[] = "DoesThisWork.txt";
char newfile[] = "DoesThisWork2.txt";
extractfiledata(oldfile, newfile);
return 0;
}
I'm basically trying to copy text from one file over to another file via strings. Any help is appreciated, thanks ahead of time.