新手求教,C语言中指针作用是什么,为什么大部分人禁用goto?
自己编写程序中(刚刚学习,写的比较简单),感觉都没用到指针也没有,运用指针处理的习惯,但是据说C语言重点就是指针的运用,所以想请教一下什么地方要用指针。
[解决办法]
const int FilterScaleFactor = 2;
float *Input = NULL, *Filtered = NULL, *Output = NULL;
float *FilterRhoSamples = NULL, *RhoSamples = NULL;
int *BestStencil = NULL;
unsigned long StartTime0, StartTime;
int IntegerScaleFactor = (int)(Param.ScaleFactor + 0.5);
int InputWidth, InputHeight, OutputWidth, OutputHeight, OutputNumEl;
int i, Success = 1;
printf("Interp stencils... \t");
StartTime = Clock();
if(!(*SInterp = NewSInterp(StencilSet,
(float)Param.RhoSigmaTangent, (float)Param.RhoSigmaNormal)))
goto Catch;
printf("%7.3f s\n", (Clock() - StartTime)*0.001f);
if(!WriteImage(Output, OutputWidth, OutputHeight, Param.OutputFile,
IMAGEIO_FLOAT
[解决办法]
IMAGEIO_RGB, Param.JpegQuality)){
goto Catch;
}
//and so on
Success = 1;
Catch:
Free(Filtered);
Free(Output);
Free(BestStencil);
Free(Input);
Free(RhoSamples);
Free(FilterRhoSamples);
return Success;
void swap(int &a, int &b)
{
int temp(a);
a = b;
b = temp;
}
template<typename T>
void swap(T &&a, T &&b)
{
T temp = std::move(a);
a = std::move(b);
b = std::move(temp);
}