Click here to Skip to main content
15,911,315 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to write source code result to file(urgent) Pin
Cedric Moonen2-May-06 20:33
Cedric Moonen2-May-06 20:33 
GeneralRe: how to write source code result to file(urgent) Pin
kakan2-May-06 20:39
professionalkakan2-May-06 20:39 
GeneralRe: how to write source code result to file(urgent) Pin
makaveli_072-May-06 20:37
makaveli_072-May-06 20:37 
AnswerRe: how to write source code result to file(urgent) Pin
Cedric Moonen2-May-06 20:31
Cedric Moonen2-May-06 20:31 
GeneralRe: how to write source code result to file(urgent) Pin
makaveli_072-May-06 20:36
makaveli_072-May-06 20:36 
GeneralRe: how to write source code result to file(urgent) Pin
Cedric Moonen2-May-06 20:43
Cedric Moonen2-May-06 20:43 
GeneralRe: how to write source code result to file(urgent) Pin
makaveli_072-May-06 20:57
makaveli_072-May-06 20:57 
GeneralRe: how to write source code result to file(urgent) Pin
Cedric Moonen2-May-06 21:08
Cedric Moonen2-May-06 21:08 
OMG | :OMG:
I suggest you read some good book about C++. It seems that you are lacking some of the fundamental syntax. I don't say that to be mean but it is a suggestion.

Now, for the code: when I say in the function that means inside the function, not outside Wink | ;) :

void DoStuff()
{
    ofstream File("MyFile.txt");


And if you declared the variable as File, use it with the same name (not as file):
void DoStuff()
{
ofstream File("MyFile.txt");

// Get the input from the user.
cout<< "Enter digit: ";
string s;
cin >> s;
cout<< endl;

for (int i=0; i<500; ++i)
{
random_shuffle(s.begin(), s.end());
File<< "Randomised: " << s << endl;
File<< " : " << s << endl;
File<< " : " << s << endl;
File<< " : " << s << endl;
File<< " "<< endl;

File<< "Single Row: " << s << " " << s << " " << s <<" " << s << endl;
File<< " "<< endl;
File<< " "<< endl;
File<< " "<< endl;
File<< " "<< endl;
} 
}


And of course, if you replace the firsts cout with File, the question (asking the user to enter the number of digits) will also be redirected to the file. That looks logical no ?
GeneralRe: how to write source code result to file(urgent) Pin
makaveli_072-May-06 21:19
makaveli_072-May-06 21:19 
GeneralRe: how to write source code result to file(urgent) Pin
Cedric Moonen2-May-06 21:27
Cedric Moonen2-May-06 21:27 
GeneralRe: how to write source code result to file(urgent) Pin
Ryan Binns2-May-06 21:42
Ryan Binns2-May-06 21:42 
GeneralRe: how to write source code result to file(urgent) Pin
makaveli_072-May-06 21:50
makaveli_072-May-06 21:50 
GeneralRe: how to write source code result to file(urgent) Pin
toxcct2-May-06 21:54
toxcct2-May-06 21:54 
GeneralRe: how to write source code result to file(urgent) Pin
Ryan Binns2-May-06 23:32
Ryan Binns2-May-06 23:32 
GeneralRe: how to write source code result to file(urgent) Pin
makaveli_072-May-06 21:51
makaveli_072-May-06 21:51 
GeneralRe: how to write source code result to file(urgent) Pin
toxcct2-May-06 21:51
toxcct2-May-06 21:51 
GeneralRe: how to write source code result to file(urgent) Pin
makaveli_072-May-06 21:54
makaveli_072-May-06 21:54 
QuestionWindows Services Pin
prajwolkumar2-May-06 19:37
prajwolkumar2-May-06 19:37 
AnswerRe: Windows Services Pin
kiran janaswamy2-May-06 19:49
kiran janaswamy2-May-06 19:49 
QuestionFinding hex pattrens in file Pin
aamir ali2-May-06 19:24
aamir ali2-May-06 19:24 
AnswerRe: Finding hex pattrens in file Pin
Nibu babu thomas2-May-06 22:06
Nibu babu thomas2-May-06 22:06 
GeneralRe: Finding hex pattrens in file Pin
aamir ali2-May-06 23:46
aamir ali2-May-06 23:46 
QuestionProb with GetKeyState Pin
cpp_prgmer2-May-06 18:52
cpp_prgmer2-May-06 18:52 
QuestionTAPI hold/Resume Transfer Pin
sanju_kg2-May-06 18:19
sanju_kg2-May-06 18:19 
AnswerRe: TAPI hold/Resume Transfer Pin
voorugonda prashanth2-May-06 19:10
voorugonda prashanth2-May-06 19:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.