Visual C++ 5.0 compatible with C?

Visual C++ 5.0 compatible with C?

I am studying C and C++ programming on my own. I have no previous programming experience. I am using Visual C++ 5.0 to run the following example “program 8.12” written in the book Programming in ANSI C, revised edition by S. G. Kochan. But Visual C++ 5.0 would not even compile it. Is this the backward compatibility problem of Visual C++ 5.0? There are 24 errors. The error started from “int i;” in the beginning of main(), it read “C2235 ‘;’ in formal parameter list.

// Program 8.12// Sort an array of intergers into ascending order.#include void sort (int a[], int n){	int i, j, temp;	for (i = 0; i < n-1; ++i)		for (j = i + 1; j < n; ++j)			if (a[i] > a[j])			{				temp = a[i];				a[i] = a[j];				a[j] = temp;			}}void main ()( 	int i;	int array[16] = {34, -5, 6, 0, 12, 100, 56, 22, 44, -3, -9, 12, 17, 22, 6, 11};		void sort (int a[], int n);	printf ("The array before the sort:
");			for ( i = 0; i < 16; ++i)	printf ("%i ", array[i]);	sort (array, 16);	printf ("

The array after the sort:
");	for ( i = 0; i < 16; ++i)		printf ("%i ", array[i]);	printf ("

Visual C++ 5.0 is indeed compatible with C and the code you posted looks pretty clean. There was just one problem: the line following void main () has an open parenthasis ("(") instead of an open curly brace ("{"). I changed it to a curly brace and it compiled just fine.

See also - an AI reverse image search platform

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist