Hi friends;
I am tring to write a program in which I have to enter different kind of input conataining integers and characters. Each input is then checked for correct spelling and correct formatting. I am using cin.get() to store the input. Everything is working just fine. It is over 500 lines long program. The problem is that each time I want to enter new input, I have to start program again. While loop does not seem to work here. What I want is that each time I am finished entering one input, I should have the choice to enter n to terminate program. If I use gets() instead of cin.get, then while loop works fine but then input gets stored incorrectly. I hope I have made my problem clear. Can ANYONE here help?
This is a grossly cut-down version of the program.
#include <iostream.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
int main()
{
clrscr();
char String[35];
char ans = 'y';
while ( ans != 'n') {
clrscr();
cout << "Enter text:";
cin.get(String, 35);
//gets(String);
cout << "\nYou entered: " << String;
cout << "\n\n\nEnter more text. Enter n if you want to terminate.";
cin >> ans;
} // end while loop
return 0;
}