Please note that I understand that this topic is old and was written in 2004. I am having a similar issue with a few codes that I have written from a book's tutorial. The program has worked with an older compiler; I am currently using Visual Studio 2005 writting a C program and get the following errors:

error C2296: '&' : illegal, left operand has type 'const char [19]'

My code is as follows:

#include <stdio.h>
#include <conio.h>


int main()
{
	int num1, num2;
	
	printf("Enter two integers I will tell you the relationship they satisfy: \n");
	scanf("%d%d", &num1,&num2);

	if (num1 == num2)
		printf( "%d is equal to %d\n" &num1, &num2 );
	if (num1 != num2)
		printf("%d is not equal to %d\n" &num1, &num2);
	if (num1 > num2)
		printf("%d is greater than %d\n" &num1, &num2);
	if (num1 < num2)
		printf("%d is less than %d\n" &num1, &num2);
	if (num1 => num2)
		printf("%d is greater than or equal to %d\n" &num1, &num2);
	if (num1 =< num2)
		printf("%d is less than or equal to %d\n" &num1, &num2);
	getchar();

	return 0;
}

Could someone please help?

Thanks

1. Your code is C, not C++ (wrong forum)
2. Your post has nothing to do with the other posts in this old thread
3. You didn't read this - http://www.daniweb.com/forums/announcement8-3.html

4. printf("%d is greater than %d\n", &num1, &num2);
You're missing a comma

5. if (num1 =< num2)
=< isn't an operator

6. If you want to print the values of both numbers, then drop all those &
As in
printf( "%d is equal to %d\n", num1, num2 );

1. Your code is C, not C++ (wrong forum)
2. Your post has nothing to do with the other posts in this old thread
3. You didn't read this - http://www.daniweb.com/forums/announcement8-3.html

4. printf("%d is greater than %d\n", &num1, &num2);
You're missing a comma

5. if (num1 =< num2)
=< isn't an operator

6. If you want to print the values of both numbers, then drop all those &
As in
printf( "%d is equal to %d\n", num1, num2 );

Thanks for your prompt response. What is the correct operator for less or equal to?

And sorry for being in the wrong forum.

@cdijuste
You knew it didn't you?? "less or equal to" "<=" :)

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.