-1

I am using the same char variable for the user to input his line into and as the image attached is showing, it won't take input from me the 2nd time or so on

running snippet with a simple main call

void WritetoFile(){
    ofstream r;
    int line=1,exit=0;
    char stringline[100];
    r.open("STORY.txt",ios::out|ios::app);
    while(exit!=1){
        cout<<"Enter your line to print into file"<<endl;
        cin.getline(stringline,100);
        r<<stringline;
        stringline[0] = 0;
        cout<<"Do you want to exit? Press 1";
        cin>>exit;
    }
    r.close();
}
Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696

0 Answers0