Please,,error in my program

I'm working on C++ visual studio 2008.
I've written a program ,and it gives me this error:

 
Error	1	general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.	.\Debug\saanother.exe.intermediate.manifest	saanother



This is my code,do you find any errors inside it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<stdio.h>          //to use the printf function
#include<conio.h>          //to use the getche function
#include <cmath>                   

int function(int x);
int moving_rule(int x[i]);
void main(){

int x0;
int t0;
int t1;
int t2;
int k=1;
printf("Enter xo :");

scanf("%d",&x0);
printf("Enter t0 :");
scanf("%d",&t0);
printf("Enter t1 :");
scanf("%d",&t1);
printf("Enter t2 :");
scanf("%d",&t2);
int x[3];
int e[3];
int x_current=x0;
int x_best=x_current;
int itterations;
int i;
printf("Enter no. of itterations");
scanf("%d",&itterations);
for(i=0;i<itterations;i++)
{
int x[3];
    int x[i+1]=moving_rule(x[i]);
    printf("%d",x[i+1]);

	e[i]=abs(function(x[i])-function(x[i+1]));}

x_current=x[i+1];
x_best=x_current;
getche(); 
}

if (function(x[i+1]<function(x[i])


	int moving_rule(int x[i]){
        int u[3];
		int u[i]=x[i]+2;
		return u[i];
	}

	int function(int x){
		int x;
		int y=(x*x+4);
		return y;}

I see two errors in there.
if (function(x[i+1] < function(x[i])
has no code underneath, and an incorrect number of parentheses.
if (function(x[i+1]) < function(x[i])) /*do what?*/ ;

1
2
3
4
5
6
7
if (function(x[i+1]<function(x[i])

	int moving_rule(int x[i]){
        int u[3];
		int u[i]=x[i]+2;
		return u[i];
	}


This is part of main() right? You are defining this function (moving_rule) here. Why?

Place function definition in another place not inside main(). If you want to call it place it inside main().

The same apply to your second function (function).

Possible places to put function definitions are:
1) Before main() in main.c. No need for function declaration her, when you want the function you call it as main() will know what this function does and how it does it.

2) After main() but inside main.c. This requires a declaration before main() as you did.

3) Inside a separate c file You write declaration in a header file, definition inside a source file and you must include the header file in your main() in order to work properly.

4) Inside a header file. You put definition inside header file and include in main(). This is normally not recommended (except for some cases like template programming where it's required)
Last edited on
SortaCore (4)::
Thank you,I forgot to put a statement..


eypros (193)::


1
2
3
4
5
This is part of main() right? You are defining this function (moving_rule) here. Why?

Place function definition in another place not inside main(). If you want to call it place it inside main().

The same apply to your second function (function).


They are functions' definitions outside main,but the error in the position of if statement.


1
2
3
4
5
6
7
8
9
Possible places to put function definitions are:
1) Before main() in main.c. No need for function declaration her, when you want the function you call it as main() will know what this function does and how it does it.

2) After main() but inside main.c. This requires a declaration before main() as you did.

3) Inside a separate c file You write declaration in a header file, definition inside a source file and you must include the header file in your main() in order to work properly.

4) Inside a header file. You put definition inside header file and include in main(). This is normally not recommended (except for some cases like template programming where it's required)
 



very Important notes ,,Thanks...
But please I have corrected the code again,,and I want a solution for this problem:

here I have x0 and x1,,and I want this code to work for more than this,,I want x[i],,related to no. of itterations that user enters it...I've tried to use anarray..but the program gives me many errors...please I want help today

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

#include"stdafx.h"
#include<stdio.h>          //to use the printf function
#include<conio.h>          //to use the getche function
#include<cmath>                   
int x0;
int x1;
int x2;
int x3;
int t0;
int t1;
int t2;
int k=1;
int p1;
int e0;
int function(int x);      //The function is: x^2+4
int moving_rule(int x);   //moving rule is : xi+2
int annealing (int x);
void main(){


printf("Enter xo :");
scanf("%d",&x0);

printf("Enter t0 :");
scanf("%d",&t0);


printf("Enter t1 :");
scanf("%d",&t1);

printf("Enter t2 :");
scanf("%d",&t2);

int x_current=x0;
int x_best=x_current;
int itterations;
int i;

printf("Enter no. of itterations less than 4\n");
scanf("%d",&itterations);

//if (itterations>3){
//printf("please enter again\n");
//scanf("%d",&itterations);}

//for(i=0;i<itterations;i++)
//{
    x1=moving_rule(x0);
	printf("x1=");
	printf("%d",x1);

	printf("\nfunction of x0 is:%d",function(x0));
    printf("\nfunction of x1 is:%d",function(x1));
   
	e0=abs(function(x0)-function(x1));
	printf("\ne0=");
	printf("%d",e0);


	
if (function(x1)<function(x0)){
x_current=x1;
x_best=x_current;
printf("\nx best is");
printf ("%d",x_best);

	if (e0==0){
printf("x is not better than");
p1=annealing(e0);
printf("\np1 is:");
printf("%d",p1);
	}
//}


//x0=x1;  //permutation to loop
//x1=x2;
	}
getche(); 

} //end of main

	int moving_rule(int x0){
        
		int u0=x0+2;
		return u0;
	}

	int function(int x){
		
		int y=(x*x+4);
		return y;
	}
    
	int annealing (int e0)

	{
		p1=expl(-e0/(t0*k));
	    return p1;
	}


anyone here?
Why "I can't do this?

1
2
3
4
5


 x[i+1]=moving_rule(x[i]);
	printf("x1=");
	printf("%d",x[i]);
That's C, not C++. You can't do it because you don't include stdio.h.
Thanks... I have included it ,,but the errors are the same..
I didn't say it would fix your errors, I said it's required for printf.

As far as your errors, I don't know what output you're trying to get, or what output you're currently getting. Also, I would recommend against using global variables, or mixing C and C++ code.
The manifest settings are in project settings under Configuration Properties>Manifest and Configuration Properties>Linker>Manifest File. You can disable manifest entirely in the latter; try doing that to fix it.
Topic archived. No new replies allowed.