필터 지우기
필터 지우기

CEC13 Linux C++

조회 수: 2 (최근 30일)
RUAN YY
RUAN YY 2020년 9월 23일
댓글: RUAN YY 2020년 9월 24일
Hey guys! I am new to Linux and currently I am working on evolutionary computation which involves CEC13 benchmark.
I found on the CEC13 website that
For Linux Users:
Please change %xx in fscanf and fprintf and do not use "WINDOWS.H".
But fscanf and fprintf seem to follow the same syntax in Linux C++, what does it refer to ? What should I modify?
The related code is as follows.
#include <WINDOWS.H>
#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include <mex.h>
.....
if (fpt==NULL)
{
printf("\n Error: Cannot open input file for reading \n");
}
.......
for (i=0; i<cf_num*nx*nx; i++)
{
fscanf(fpt,"%Lf",&M[i]);
}
....
Would you please give me some help about how to modify the code? Many thanks!
BTW, if nothing changes, the output is incorrect although it can be complied.

채택된 답변

Walter Roberson
Walter Roberson 2020년 9월 24일
For Visual Studio, %Lf stands for "long double" .
long double in Windows is the same as double. long double in gcc is a larger floating point number. This can lead to incompatibilities.
You should probably be using %lf for double instead of long double: it will not make any difference for Visual Studios and it will prevent problems for other compilers.
MATLAB does not support long double.
  댓글 수: 1
RUAN YY
RUAN YY 2020년 9월 24일
thank you so much!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model Predictive Control Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by