Have you used the extraction operator somewhere previous to this function? If so you have you tried to ignore() what is in the buffer?
Why is this function named write when you're getting information from the user (reading). You should probably try to separate the input from the output.
Since you used the extraction operator with the cin stream there is a end of line character that you need to ignore(). Any time you switch between using the extraction operator and getline() you need to make sure the end of line character is removed from the stream before you switch to getline().
There is a pinned topic "Console Closing Down" that you may want to read, since the first or second post shows you how to ignore() things left in the input buffer.
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
usingnamespace std;
void get_and_store_question();
int main()
{
int user;
cout << "Enter a number" << endl
<< "1.) Enter questions" << endl
<< "2.) Enter anwsers" << endl
<< "3.) Quit program" << endl;
cin >> user;
switch (user)//user selects
{
case 1:
get_and_store_question();
break;
}
}
void get_and_store_question()
{
// you don't give input a value before you call the function, so why does
// the function need it as an argument?
constchar* fname = "C:/Users/Jack/Desktop/biology_flash_cards.txt";
std::ofstream out(fname, std::ios_base::app);
if (!out)
{
std::cout << "Unable to open file \"" << fname << "\"\n";
return;
}
std::cout << "Enter a question:\n> ";
std::string question;
std::getline(std::cin >> std::ws, question);
// http://en.cppreference.com/w/cpp/io/manip/ws
out << question << '\n';
// out is automagically closed here
}