A
Allen
How can I pass a file to a function? If tried the code below (using
string* or String*) I got:
"error C2143: syntax error : missing ')' before '*' "
//The function in "Time.ccp"
void Time::WriteToFile(String* path)
{
FileStream* fs = new FileStream(path, FileMode::Create);
StreamWriter* sw = new StreamWriter(fs);
String* TimeString = (System:ateTime::Now.ToString("mm"));
sw->WriteLine(TimeString);
sw->Flush();
sw->Close();
}
// "Time.h"
__gc class Time
{
public:
Time (string* path);
void WriteToFile(string* path);
void Time::ReadFromFile();
private:
string* path;
};
//Call the function from the handler
private: System::Void InBtn_Click(System::Object * sender,
System::EventArgs * e)
{
Time * Employee1;
Employee1 = new Time;
Employee1->WriteToFile(S"TimeX.txt");
}
string* or String*) I got:
"error C2143: syntax error : missing ')' before '*' "
//The function in "Time.ccp"
void Time::WriteToFile(String* path)
{
FileStream* fs = new FileStream(path, FileMode::Create);
StreamWriter* sw = new StreamWriter(fs);
String* TimeString = (System:ateTime::Now.ToString("mm"));
sw->WriteLine(TimeString);
sw->Flush();
sw->Close();
}
// "Time.h"
__gc class Time
{
public:
Time (string* path);
void WriteToFile(string* path);
void Time::ReadFromFile();
private:
string* path;
};
//Call the function from the handler
private: System::Void InBtn_Click(System::Object * sender,
System::EventArgs * e)
{
Time * Employee1;
Employee1 = new Time;
Employee1->WriteToFile(S"TimeX.txt");
}