[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] EOF key-Combination inside Eclipse CDT

Please help if you know how to fix it to enable my C program run to completion:

My test program running under Eclipse 3.3.2 CDT with output shown on the Eclipse console could not have recognized the EOF key stroke (CTL-D under Unix/Linux and CTL-Z under Windows). This seems to be a tricky problem to solve inside Eclipse. Please note the same programs runs fine under my cygwin X-Term with CTL-D. I have installed the 'cygwin" toolchain to work with my Eclipse 3.3.2 CDT.

Here is the simple program to create a sequential file:

/* Tutorial 07 - Example 01
* Listing 7.1 - Creating a sequential file
*/

#include <stdio.h>

main()
{
	int account;
	char name[30];
	float balance;
	FILE *cfPtr;
	if ((cfPtr = fopen("clients.dat", "w"))== NULL)
		printf ("File could not be open\n");
	else {
		printf ("Enter the account number, name, and balance.\n");
		printf ("Enter EOF to end input.\n");
		printf ("? ");
		fflush (stdout);
		scanf ("%d%s%f", &account, name, &balance);
		while (!feof(stdin)){
			fprintf (cfPtr, "%d %s %.2f\n", account, name, balance);
			printf ("? ");
			fflush (stdout);
			scanf ("%d%s%f", &account, name, &balance);
		}
		fclose (cfPtr);
	}
	return 0;
}

I am looking foreward to hearing from you.

Thanks.

Kam