OK - your program should compile and link without the error, without you having to do anything special. In other words, you shouldn't have to "#include windows.h" (although it couldn't hurt) and you shouldn't have to explicitly use "tmain()" (even though that's the actual entry, behind the MSVC macros).
It should "just work".
SUGGESTIONS:
1) Verify that you can compile, link and execute ANY C program. For example:
a) Type in this program:
notepad tmp.c
#include <stdio.h>
int main() {
printf ("Hello world!\n");
return 0;
}
b) Compile: from the MSVS IDE, or from the command line (you can use the MSVS .bat file "vcvars32.bat" to set your command prompt environment:
d:\temp>cl tmp.c
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
tmp.c
Microsoft (R) Incremental Linker Version 11.00.50727.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:tmp.exe
tmp.obj
c: Execute your program: D:\temp>tmp
Hello world!
2) I have a different, newer version of MSVS ... but it should absolutely work the same for your MSVS 2008.
3) If your "hello world" (new MSVS project and/or command line build) fails with the same link error, you might want to consider re-installing MSVS. Consider getting a newer version (e.g. Visual Studio 2013 Community), if at all possible:
http://www.visualstudio.com/
MSVS 2012 Express
4) If your "hello world" works (and it should), consider creating a new project from scratch, then copying your files into the new project.
This complete example compiles and runs OK for me:
#include <stdio.h>
#include <string.h>
#define MAX_NAME 30
#define MAX_LINE 80
#define CLIENTS_FILE "clients.dat"
int main () {
char line[MAX_LINE], acct_name[MAX_NAME];
unsigned int acct_no;
double acct_balance;
int iret;
/* Open file. Print error and return non-zero status if error */
FILE *fp = fopen(CLIENTS_FILE, "w" );
if (!fp) {
perror ("clients file open error");
return 1;
}
do {
/* Get next record */
printf ("Enter the account, name, and balance. \"q\" to exit.\n");
fgets (line, MAX_LINE, stdin);
/* Check for end of data */
if (line[0] == 'q')
break;
/* Parse data */
if ((iret = sscanf(line, "%d %s %lf", &acct_no, acct_name, &acct_balance )) == 3) {
/* Write to file */
fprintf(fp, "%d %s %lf\n", acct_no, acct_name, acct_balance );
} else {
/* Print warning */
printf ("Error: unable to parse input: #/items parsed = %d, line = %s", iret, line);
}
} while (line[0] != 'q');
/* Close file and return "OK" status */
fclose (fp);
printf ("Done.\n");
return 0;
}