本文整理汇总了C++中FileInputStream::getLastError方法的典型用法代码示例。如果您正苦于以下问题:C++ FileInputStream::getLastError方法的具体用法?C++ FileInputStream::getLastError怎么用?C++ FileInputStream::getLastError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileInputStream
的用法示例。
在下文中一共展示了FileInputStream::getLastError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// test function for expressions
int main() {
ProductExpression *expression =
new ProductExpression(
new PowerExpression(
new ConstantExpression( 5 ),
new ConstantExpression( 6 ) ),
new NegateExpression(
new SinExpression(
new ConstantExpression( 19 ) ) ) );
InvertExpression *invExpression = new InvertExpression( expression );
SumExpression *sumExpression = new SumExpression(
invExpression, new ConstantExpression( 2 ) );
sumExpression->print();
printf( "\n" );
printf( "%f\n", sumExpression->evaluate() );
printf( "Writing to file.\n" );
char **pathSteps = new char*[2];
pathSteps[0] = new char[10];
pathSteps[1] = new char[10];
sprintf( pathSteps[0], "test" );
sprintf( pathSteps[1], "file" );
int *stepLength = new int[2];
stepLength[0] = 4;
stepLength[1] = 4;
Path *path = new Path( pathSteps, 2, stepLength, false );
File *file = new File( path, "test.out", 8 );
FileOutputStream *outStream = new FileOutputStream( file, false );
char *error = outStream->getLastError();
if( error != NULL ) {
printf( "Error: %s\n", error );
delete error;
}
ExpressionSerializer::serializeExpression( sumExpression, outStream );
delete outStream;
delete file;
printf( "Reading back in from file.\n" );
pathSteps = new char*[2];
pathSteps[0] = new char[10];
pathSteps[1] = new char[10];
sprintf( pathSteps[0], "test" );
sprintf( pathSteps[1], "file" );
stepLength = new int[2];
stepLength[0] = 4;
stepLength[1] = 4;
path = new Path( pathSteps, 2, stepLength, false );
file = new File( path, "test.out", 8 );
FileInputStream *inStream = new FileInputStream( file );
error = inStream->getLastError();
if( error != NULL ) {
printf( "Error: %s\n", error );
delete error;
}
Expression *readExpression;
ExpressionSerializer::deserializeExpression( &readExpression,
inStream );
delete inStream;
delete file;
readExpression->print();
printf( "\n" );
printf( "%f\n", readExpression->evaluate() );
delete sumExpression;
delete readExpression;
return 0;
}