The code below works in writing tool.toolName, tool.quant, and tool.cost into a file when toolName is one word ("hammer", e.g.). But it doesn't work when toolName is more than one word ("power drill", e.g.). I've tried using cin.getline(line, 20), cin.getline(tool.toolName, 20), etc, but can't get it to work. toolName is a char[20]. I could try string, but since this is supposed to be a fixed length record, I don't know how to limit a string length either. Any ideas? Thanks.
Code:
if (tool.recNum == 0)
	{
		cout << "\nEnter tool name, quantity and cost: ";
		cin >> tool.toolName >> tool.quant >> tool.cost;
		tool.recNum = rec;
		toolFile.seekp((rec - 1) * sizeof(toolList));
		toolFile.write((char *)&tool, sizeof(toolList));
	}