[ create a new paste ] login | about

Link: http://codepad.org/BGBDsOfd    [ raw code | output | fork ]

C++, pasted on Apr 2:
#include <cctype>
#include <cstddef>        // std::size_t
#include <direct.h>
#include <fstream>
#include <iostream>       // std::cout
#include <string>         // std::string

using namespace std;

string talk(string test), Wel(string open);
void Change(), Create(), Find(), Make(), Write();


string choice, File, hello, name, newFolder, one, open, test, user;

int main ()
{
	for ( int i = 0; i < 5; i++)
	{
	
	Wel("would you like to make a folder or write something?");
	getline(cin,hello);

	Find();

	}

system("pause");

}

string talk(string test)
{
cout << "File Input : ";
getline(cin,test);
one = test;
return one;
}

string Wel(string message)
{
	cout << message << endl;
	return message;
}

void Create()
{
	cout << "what is the files name?" << endl;
	cin >> File;
fstream inout;
inout.open(newFolder + "\\" + File,ios::out | ios::app);
inout.close();

}

void Find()
{
	string str = hello;
	for (char& ch : str)
		ch = tolower(ch);

	 size_t found = str.find("make");
  if (found != string::npos)
  {
	  Make();
	  Create();
  }

  found = str.find("write");
   if (found != string::npos)
   {
	   Change();
	   talk(test);
	   Write();
   }
}

void Make()
{
	cout << "What is the name of the new folder" << endl;
	cin >> newFolder;
	_mkdir((newFolder.c_str()));
}

void Write()
  {
fstream inout;
inout.open(newFolder + "\\" + File,ios::out | ios::app);
  inout << one << endl;
  inout.close();
  }

void Change()
{
	cout << " current path : " << newFolder << " \\ " << File << endl;
	cout << " \n would you like to change directories ? Folder (1) , File (2) , both (3), continue(4):";
	getline(cin,choice);
	choice =(atoi(choice.c_str()));

	switch (choice[0])
	{
	case 1: 
		cout << "Folder :";
		getline(cin,newFolder);
		break;
	case 2:
		cout << "File :";
		getline(cin,File);
		break;
	case 3:
		cout << "Folder :";
		getline(cin,newFolder);
		cout << "File :";
		getline(cin,File);
	default:
		break;
	}
}


Output:
1
2
3
4
Line 19: error: direct.h: No such file or directory
In function 'void Create()':
Line 51: error: no matching function for call to 'std::basic_fstream<char, std::char_traits<char> >::open(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::_Ios_Openmode)'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: