#include <stdio.h>
#include <conio.h>
#include <iomanip.h>
#include <ctype.h>
#include <string.h>
#include <iostream.h>
#define input "d:\\tcpp\\bin\\files\\input.txt"
#define tempo "d:\\tcpp\\bin\\files\\tempo.txt"
void menu(void)
{
cout << "Menu\n\n";
cout << "A - Add\n";
cout << "D - Delete\n";
cout << "I - Display\n";
cout << "E - Edit\n";
cout << "S - Search\n";
cout << "X - Exit\n\n\n";
cout << "Enter your choice: ";
}
void add(void)
{
FILE *infile;
char Name[50], Target[50], Answer[3], Checker[50];
int ID = 0;
float Amount;
char Gender;
do{
clrscr();
if((infile = fopen(input, "a+")) == NULL)
ID = 1;
else
{
do{
fscanf(infile, "%i %s %c %f", &ID, Name, &Gender, &Amount);
Name = Checker;
}while(!feof(infile));
ID += 1;
}
cout << "ID : " << ID << endl;
cout << "Name: ";
cin >> Name;
cout << "Gender: ";
cin >> Gender;
cout << "Amount: ";
cin >> Amount;
/* How come this doesnt work at all ? /*
if(Name == Checker)
{
cout << "Record Exist. Cannot add. " << endl;
cout << "ID : " << ID << endl;
cout << "Name: ";
cin >> Name;
cout << "Gender: ";
cin >> Gender;
cout << "Amount: ";
cin >> Amount;
}
fprintf(infile, "%i %s %c %f\n", ID, Name, Gender, Amount);
/* How come when I work just with char Answer and [y/n] as choices it works
but if yes or no declared as strings doesn''t work? how do i fix it? */
cout << "Do you want to add another [yes/no]: ";
cin >> Answer;
fclose(infile);
}while(Answer != "no");
}
This post has been edited by issyl: 01 December 2010 - 08:26 AM

New Topic/Question
Reply




MultiQuote



|