aaye.. i suppose i m cheating .. but atlast i got this thing working.. and the user will now make entries in window and confirmation will be made to continue or exit.. all those entries will be stored in a file..
thanx everybody helping me make this code work.. thanx a lot..
any suggestions or available changes will be highly appreciated
Code:
#include <stdio.h>
#include <string.h>
#include <conio.h>
int main(void)
{
char buff[BUFSIZ]; /* general input buffer */
char name[BUFSIZ] = {30};
int age;
char ans;
FILE *pFile;
char *p, *q;
pFile = fopen( "c:\\test\\myfile.txt","at" );
clrscr();
if(pFile!=NULL)
{
do{
window(10,8,60,9);
/* read the name */
/* the last statement removes the newline (if present) which */
/* fgets() will add ( gets() doesn't add a newline ) */
cprintf( "Enter your name : " );
p = cgets(name);
cprintf( "\r\nEnter your age : " );
fgets( buff, sizeof(buff), stdin );
sscanf( buff, "%i", &age );
fprintf( pFile,"%s %d\n",p,age );
cprintf("\r\n \r\n");
cprintf( " Do you want to make another entry\r\n" );
cprintf( " 'y' to continue, 'n' to exit : ");
fgets( buff, sizeof(buff), stdin );
ans = buff[0];
clrscr();
}
while ( ans != 'n');
fclose( pFile );
}
return 0;
}