Hi Oliver. The problem is that the address of tmps, which is passed to the fscanf() is not correct. The string varibale tmps has not been properly initialized before its address is used.
Actually, scanf() is a C function while string is a C++ stuff. Better not mix them.
I suggest that you change your code like follows:
void test4()
{
#define MAXLEN 30
char cTmp[MAXLEN];
string name = "f:\\temp\\file.dat";
FILE *stream;
stream = fopen( name, "r" );
for (int m=0; m<7; m++)
{
fscanf( stream, "%s", cTmp);
string ts(cTmp, 5);
printf("%s\n", ts);
}
}
Note: please modify MAXLEN as you need.
Deanna
OriginLab Technical Services
Edited by - Deanna on 10/22/2006 11:23:41 PM