<DIV>Hi,</DIV>
<DIV>I want to write the result of observer to a file called Observer_Result.txt</DIV>
<DIV>and my code is as follows, but why there is onthing in the file?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> void Execute(const itk::Object * object, const itk::EventObject & event)<BR> {<BR> OptimizerPointer optimizer = <BR> dynamic_cast< OptimizerPointer >( object );<BR> if( typeid( event ) != typeid( itk::IterationEvent ) )<BR> {<BR> return;<BR> }<BR> std::cout << optimizer->GetCurrentIteration() << " ";<BR> std::cout << optimizer->GetValue() << " ";<BR> std::cout << optimizer->GetCurrentPosition() << std::endl;<BR> /////////////////////////////////write to file<BR> FILE *stream1;</DIV>
<DIV> char fileName1[]= "Observer_Result.txt";<BR> if( (stream1 = fopen( fileName1, "a+t" )) != NULL )<BR> { <BR> fprintf( stream1, "%d\t", optimizer->GetCurrentIteration());<BR> fprintf( stream1, "%e\t",optimizer->GetValue());</DIV>
<DIV> OptimizerType::ParametersType observerParameters = <BR> optimizer->GetCurrentPosition();<BR> <BR> fprintf( stream1, "%e\t", observerParameters[0]);<BR> fprintf( stream1, "%e\t", observerParameters[1]);<BR> fprintf( stream1, "%e\t", observerParameters[2]);<BR> fprintf( stream1, "%e\t", observerParameters[3]);<BR> fprintf( stream1, "%e\t", observerParameters[4]);<BR> fprintf( stream1, "%e\t\n", observerParameters[5]);</DIV>
<DIV> }<BR> <BR> }</DIV><BR><BR><DIV>
<DIV><STRONG><FONT color=#00007f>Best Regards!</FONT></STRONG></DIV>
<DIV><STRONG><FONT color=#00007f></FONT></STRONG> </DIV>
<DIV><STRONG><FONT color=#00007f>Yu Qi</FONT></STRONG></DIV>
<DIV> </DIV>
<DIV> </DIV></DIV><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://music.yisou.com" target=blank>150万曲MP3疯狂搜,带您闯入音乐殿堂</a><br><a href="http://image.yisou.com" target=blank>美女明星应有尽有,搜遍美图、艳图和酷图</a><br>
<a href="http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/" target=blank>1G就是1000兆,雅虎电邮自助扩容!</a>