still the same error comes out..

I'll need the erroneous part again. Code.

/* < newton.c > */
#include "smp.h"

int main()
{
	void USERF(double *,double *,double);
	void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double *,double));
	double 	x0,e;
	int		n,NMAX;

/*** ステップ1 データの入力 ***/
	printf("\n初期値 x0 = ");
	scanf("%1f",&x0);
	printf("\n収束判別定数 p = ");
	scanf("%1f",&e);
	printf("\n最大反復回数 NMAX = ");
	scanf("%d",&NMAX);

/*** ステップ2 ニュートン・ラプソン法の計算 ***/
	S_NEWT(&n,&x0,e,NMAX,&USERF);
	return 1;

/*** ステップ3 計算結果の出力 ***/
	printf("\n反復回数:N=%d 解:X(N)=%10.71e",n,x0);
}

/* < ニュートン・ラプソン法の関数 > */
void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double *,double))
/*	n		: スカラー	反復回数		(Out)
	x0		: スカラー	初期値(解)		(In/Out)
	e		: スカラー	収束判別定数	(In)
	NMAX	: スカラー	最大反復回数	(In)
	FUNC	:			ユーザ定義関数	(In)	*/
{
     double fun,dfun,xn,ans;
     for(*n=0,xn=*x0;*n<NMAX;){
		(*FUNC)(&fun,&dfun,xn);
		*x0=xn-fun/dfun;
		if(fabs(xn-*x0)>e)
	    	xn=*x0;
	else
	    break;
      }
}

/* <ユーザ定義の関数とその微分の関数 > */
void USERF(double *fn,double *dfn,double x)
/*	fn	: スカラー	方程式			(Out)
	dfn	: スカラー	方程式の微分	(Out)
	x	: スカラー	入力値			(In)	*/
{
double x2;
x2=x*x;
*fn=x2*x-1.0;
*dfn=3.0*x2;
return;
}
int main()
{
void USERF(double *,double *,double);
void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double *,double));

I give up, it can go for hours with me trying to show you the way, all in vain. I thought you yourself would "get" the solution. Here goes:
remove these declarations:
void USERF(double *,double *,double);
void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double

from main() to global scope.

btw, thanks for your effort, i really appriciate that

Is your problem solved now? If yes please mark this as solved.

no, not solved

Still the same error, even after removing those declarations to above int main()?

Out of curiosity I compiled your code & this worked all fine. Don't know what you are doing wrong.

#include <stdio.h>
#include <math.h>
void USERF(double *,double *,double);
void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double *,double));

int main()
{
	double 	x0,e;
	int		n,NMAX;

	printf("\n??? x0 = ");
	scanf("%1f",&x0);
	printf("\n?????? p = ");
	scanf("%1f",&e);
	printf("\n?????? NMAX = ");
	scanf("%d",&NMAX);

	S_NEWT(&n,&x0,e,NMAX,&USERF);


	printf("\n????:N=%d ?:X(N)=%10.71e",n,x0);
   return 1;
}

void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double *,double))

{
     double fun,dfun,xn,ans;
     for(*n=0,xn=*x0;*n<NMAX;)
     {
		(*FUNC)(&fun,&dfun,xn);
		*x0=xn-fun/dfun;
		if(fabs(xn-*x0)>e)
	    	xn=*x0;
		else
	    break;
      }
}


void USERF(double *fn,double *dfn,double x)
{
double x2;
x2=x*x;
*fn=x2*x-1.0;
*dfn=3.0*x2;
return;
}
commented: Rep for helping in this monster thread +4
main()
{
	void USERF(double *,double *,double);
.
.
}

You can't declare functions-in-functions in C, perhaps in JavaScript or Pascal but not in C/C++. Take that declaration outside main().

Actually you are wrong, you can declare functions inside functions like that. What you can't do is define functions inside other functions like this

int main()
{
	void USERF(double *,double *,double)
	{
	}
.
.
   return 0;
}
commented: Really! I didn't know that. Thanks for the info. +1

more errors, why dont u test to compile these codes before posting it here

Out of curiosity I compiled your code & this worked all fine. Don't know what you are doing wrong.

#include <stdio.h>
#include <math.h>
void USERF(double *,double *,double);
void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double *,double));

int main()
{
	double 	x0,e;
	int		n,NMAX;

	printf("\n??? x0 = ");
	scanf("%1f",&x0);
	printf("\n?????? p = ");
	scanf("%1f",&e);
	printf("\n?????? NMAX = ");
	scanf("%d",&NMAX);

	S_NEWT(&n,&x0,e,NMAX,&USERF);


	printf("\n????:N=%d ?:X(N)=%10.71e",n,x0);
   return 1;
}

void S_NEWT(int *n,double *x0,double e,int NMAX,void (*FUNC)(double *,double *,double))

{
     double fun,dfun,xn,ans;
     for(*n=0,xn=*x0;*n<NMAX;)
     {
		(*FUNC)(&fun,&dfun,xn);
		*x0=xn-fun/dfun;
		if(fabs(xn-*x0)>e)
	    	xn=*x0;
		else
	    break;
      }
}


void USERF(double *fn,double *dfn,double x)
{
double x2;
x2=x*x;
*fn=x2*x-1.0;
*dfn=3.0*x2;
return;
}

yes, it works fine but not working when #include smp.h ?

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>

#define pi 2.0 * acos(0) /* π */
#define e_eps 1.0e-15 /*ピボットの許容最小値、零判定値*/

void S_ADAM(double *,double ,double ,int ,int ,double ,double (*)());
void S_FDBS(double *,double *,int *,double *,int ,int );
void S_HAUS(double *,int ,double *,double *,double *);
void S_INMG(double *,int ,int ,char *);
void S_INMS(double *,int ,int ,char *);
void S_EULR(double *,double ,double ,int ,double (*)());
void S_NEWT(int *,double *,double ,int ,double (*)());
void S_OUTM(double *,int ,int ,char *);
void S_QR(double *,int ,double ,double *,double *);
void S_RNGK(double *,double ,double ,int ,double (*)());
void S_SPLN(double *,double *,double *,int ,double *,
double *,double *,double *);
int S_CHOL(double *,double *,double *,int );
int S_DOT(double *, int , int *);
int S_EIGN(double *,double *,int ,double ,double *,double *,
double *,double *,int *);
int S_GAUS(double *,double *,double *,int );
int S_INVM(double *,double *,int ,int *);
int S_INVG(double *,double *,int ,int ,int *,double *);
int S_JACB(double *,double *,int ,int ,double );
int S_LSM(double *,double *,double *,int ,int ,double *,double *);
int S_PIVO(double *, int *, int , int );
int S_RUNG(double *,int ,double ,double ,int ,int ,
void (*)(),double *,double *,double *);
double S_DAIK(double ,double ,int ,double (*)());
double S_LAGR(int ,double *,double *,double );
double S_ROMB(double ,double ,double ,int ,double (*)(),double *);
double S_SPFN(double *,double *,double *,int ,
double *,double *,double );

this is the smp.h codes

Honestly i think with your attitude not much people will try to help. You are not stupid, but you are really lazy. What is the purpose of studies if someone else do all the work for you? And your replies are really rude, people tried to help you but you just take it for granted.

Actually you are wrong, you can declare functions inside functions like that.

Thanks for the info Banfa. Appreciated. :)

more errors, why dont u test to compile these codes before posting it here

In case you missed my post, I already had. Quit cribbing about it.

yes, it works fine but not working when #include smp.h ?

Gracias, then your header file is to blame. It took me almost half a day to correct your single function, Sorry but you'll have to figure them out yourselves in the similar way. I wish you best of luck & a hint.

void S_EULR(double *,double ,double ,int ,double (*)());
void S_NEWT(int *,double *,double ,int ,double (*)());    //Change this & remove declaration in main.cpp
void S_OUTM(double *,int ,int ,char *);
void S_QR(double *,int ,double ,double *,double *);
void S_RNGK(double *,double ,double ,int ,double (*)())

Well so much for hint. But if you can't figure this one out, I'm sorry to say you don't deserve to get helped. After all DaniWeb helps those who helps themselves. (Let's not bring god into the picture, shall we.)

Firstly its a warning not an error, the program still compiled and possibly worked. However that said plenty of programmers use the rule of thumb that all warning should be dealt with and the program should compile without warnings.

You have declared S_NEWT as taking a pointer function with no parameters but supplied it with a pointer to a function that takes 3 parameters. Try fixing the prototype of S_NEWT to take account of the 3 parameters in USERF.

youre right, the program works! thanks to you,!!!

Thanks for the info Banfa. Appreciated. :)

In case you missed my post, I already had. Quit cribbing about it.

Gracias, then your header file is to blame. It took me almost half a day to correct your single function, Sorry but you'll have to figure them out yourselves in the similar way. I wish you best of luck & a hint.

void S_EULR(double *,double ,double ,int ,double (*)());
void S_NEWT(int *,double *,double ,int ,double (*)());    //Change this & remove declaration in main.cpp
void S_OUTM(double *,int ,int ,char *);
void S_QR(double *,int ,double ,double *,double *);
void S_RNGK(double *,double ,double ,int ,double (*)())

Well so much for hint. But if you can't figure this one out, I'm sorry to say you don't deserve to get helped. After all DaniWeb helps those who helps themselves. (Let's not bring god into the picture, shall we.)

thanks for your help!! the program works, but not like youre saying, u just make the programs goes wrong,and more error comes out! haha,,thanks for that and thanks for wasting my time compiling your so called junk code.!

commented: Show some appreciation and a better attitude -1
commented: Thanks for the gratitude. +0

thanks for wasting my time compiling your so called junk code.!

It wasn't mine. It was yours.

but not like youre saying

Me and Banfa practically said the same things. What you interpreted of them is entirely your take.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.